I have a very basic question. I’m running a Ruby script to access the contents of a directory in Linux. The directory is passed through the command line when the ruby script is executed.
My question is how would I use the command line argument in the command for ruby?
I have it set like such:
usrDirectory = ARGV[0]
lsCmd = `ls -l`
I need to use something like ls -l usrDirectory.
Could I just insert it into the command like is?
The above is right, and if you want to have
lsoutput to standard out, this makes it a little cleaner:This will make Ruby print the output to your standard out instead of putting the output in the variable as the above does.