YASQ Yet Another Simple Question regarding scripting
my pwd contains files and directories named nick and emptydr
Code:
ls -l|grep dwrx|cut -d' ' -f9 let's say I save the result of the above command into a file named listing. then the file listing will contain the following" nick emptydr and now, I would like to write my script so my script uses each line in the file named listing as the input of the file. How can I do that? thanks |
I think you want the "read" command.
For example, this: read line1 < filename reads the first line of "filename" into the variable "line1" You could do it in a loop in which each invocation of "read" puts a line into an array, indexing the array as you go. I recommend going to tldp.org and getting the Advanced Bash Scripting Guide. Unless you have a personal forest, don't print it!! I just use it for searches. |
Code:
ls -l|grep dwrx Code:
ls -l| grep ^d and then using result (here I simply use echo to print each line): Code:
cat file | while read i; do echo $i; done |
All times are GMT -5. The time now is 08:17 AM. |