Help Urgent With Find Command!!
hi
I used find command to find some file names as per input from user. I used it for current directory. It was working fine. Now I tried with giving some other directory path. Its giving issues. Here what I tried. Script will take input from user say 1_abc.txt, find the file and print list. if files are not there it will print No Files with this name message. Finding files in the current Directory. Code:
echo View Log files; Code:
echo View Log files; 1. Its printing files names with fullpath i.e., /backup/test1/LogFiles/1_abc.txt This is not required. I need to print only file names. 2. The if statement is always in execution. Its always printing the "No Files with this name" statement. Simply its not working. I tried to use find with -P -H options but not of use. Urgent help is needed. Please help me to make it work. Thanks, |
sukhdip;
You've been here long enough to know not to put "urgent" in posts---but you DO have a good record of saying "please" and "thank you"---:) I looked thru the man page for "find", and I did not find a way to tell it not to print the full pathname (It might be there--I just ran out of patience). The easy way out: Code:
find <location> -name "<search string>" | sed 's#.*/##' As for the test statement--I'd start by adding a diagnostice statement that prints out what is actually getting written to "errorlog" |
Quote:
I will try with your given method. I will post the result after that. |
Running find with -printf "%f\n" will display bare file names.
|
Quote:
|
Quote:
|
Hi everybody thanks for your help.
I solved it. Code:
find /backup/test1/LogFiles/$filename"_"*.* ........ |
Quote:
sometimes I follow the rule we used in our early 60s motorcycle shop: "If it works, it's OK". Trust me, when dealing with British bikes from the 40s and 50s, we NEEDED that rule.....;) |
All times are GMT -5. The time now is 01:33 AM. |