Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same.
Thanks in advance.
Regards
Jatin Jain
Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same.
Thanks in advance.
Regards
Jatin Jain
the only reason i guess you can't use find is you might be doing homework. but nevertheless .. if you can't use find, use locate? the other way is to use ls with -R option.
Hi Ghost,
i tried using ls but how to do it recursively ls -r ?. It dint work for me
i will show u a snippet of my script
#!/bin/sh
echo $1 #display the input entered
c=$1
ls -l $c | awk `(if(NR>0) pwd)` # usinf ls command and awk i m trying to get those records and print its path,pwd is not working there
assuming you know the file name
#!/bin/sh
ls -lR / | awk -v filename="$1" '/^\//{ dir=$0}
/^-/{ if ( $9 == filename ) {
print "Found " filename " in "dir
}
}'
awk: syntax error near line 1
awk: bailing out near line 1
whts this
what did you do? show your code.
#!/bin/sh
ls -lR / | awk -v filename="$1"
'/\//{ dir=$0}
/^-/{ if ( $9 == filename ) {
print "Found : " filename " in " dir
}
}'
I think its the same as u had posted.
Let me know if here is some syntax mistake
no its not.
check again.
He ghost can u add me on any of the messengr.t would be very helpful.I knw i forgot to add a carrot (^) earlier but i made the changes.still nt getting the desired ouptut.Add me on snipped if possible or give me ur some other messenger id .I would do so
If i were you , this is what i would do
$ ls -lRt | grep $filename
<notice the 'R' , its list RECURSIVE>
-Samarth
With the Z-Shell:
print -l **/filename(N)