a question to a special ls
Hi
Can anyone explain me in detail the follwing instructions (line 1 and 2 only). ls | \ while IFS= read filename do (something) done Thanks in advance. Regards Lazy |
Hi and welcome to LQ.
The code you've posted executes a while loop taking input from the ls command. This is a method to read a block of text line by line and execute some actions over each line. More in details the ls command list the files in the current directory and pipe this list to the while loop. The backslash at the end of the line is not really necessary. In shell programming it simply means that the statement continues on the next line, but the pipe acts in the same way. The while loop just reads the input and assigns every line to the shell variable "filename". The syntax is: Code:
while command Code:
IFS= read filename Code:
IFS= |
Quote:
|
Thanks guys for the prompt replies - it's quite clear now. In the mean time my recursive script works as it should. Regards - Lazy
|
All times are GMT -5. The time now is 03:00 PM. |