checking presence of a file identified/ addressed by a variable
hi,
I am newbie in Linux shell scripting.Can anybody help me to check the presence of file identified by variable in Shell scripting? For example: I am reading the content of a file using while command as below: "while read -r line do code block done < file_name" Now in this case every line in file gets stored in the variable 'line' one by one.Problem here is every line in the file is nothing but the file_path of another file say xyz.txt and I am checking presence of this xyz.txt file using below command: if [-f $line] as 'line' is the variable which stores file path of xyz.txt but it is not working. It is unable to check the presence of this xyz.txt file as i am addressing it with the variable 'line'. Please help me.Thanks in advance. |
you should show us the real script, otherwise it will be very hard. But probably you only missed a space:
Code:
if [ -f $line ] |
Thanks a lot pan64!!
I didn't five space before '-f' and it is working now. |
All times are GMT -5. The time now is 11:47 AM. |