Hi, I've a file containing file names along with their path. I need a script which checks each line in that file which has file names along with their path and display if a particular file exists or not.
file.txt which has file names along with their path
I tried with this below mentioned code, but unable to get desired output.
Requesting guidance in this regard. Thanks.
ls * shows a listing of the current working directory. It does not include the paths given in your file.
Why don't you read the file line by line in a while loop and use shell parameter expansion for the existence tests?
Thanks for your reply RudiC. I just tried with do-while loop.
I'm getting desired output of long listing of files via "ls -lrt" command. But i need to upgrade this one step ahead by including probably an if-else condition (pls correct if i'm wrong) to check if a particular file exists or not. Could you please suggest?
Why isn't the diagnostic output from ls sufficient to let you know that a file doesn't exist? If for some reason, you do need to test for a file's existence (without caring what its size is):
RudiC, Don C, saps19 Thanks each one of you. I did try looking at your posts. This is good learning for me. Thanks indeed for giving direction to think.