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 ls output to standard out, this makes it a little cleaner:
system("ls", "-l", dir)
This will make Ruby print the output to your standard out instead of putting the output in the variable as the above does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With