Search for file by name or owner

Hi

I am trying to write a 1 line command to search for a file with either a certain username or owned by a certain owner using ls and I/O redirection only. I was wondering if there is something like an “OR” statement in linux which would allow me to do this. What I have so far is
ls -l file1* OR ls -l|awk ‘{print $3}’|grep ishan
I need something to replace the OR here, coz at the moment I am getting a syntax error here.

You’re using the wrong tool. Look at the “find” program.

I do not know where you have this statement from, but in reality there are two statemenst there, where the original writer says that you should use the one or the other. So you could use

ls -l|awk '{print $3}'|grep ishan

which btw should give you as many lines with the word *ishan *as there are files owned by *ishan in the working directory. *Is that really what you want? Else read the man page for *find *as ken_yap suggest, or formulate better what you want to achieve.

Reading again and again what you wrote, I come to the idea that you might try to do the following:

ls -l file1

and if that does not give any file/directorie then execute

ls -l|awk '{print $3}'|grep ishan

When that is the case this can be done in *bash *by

ls -l file1 || ls -l | awk '{print $3}' | grep ishan

I do not know of any shell who has OR as the same construct, but *bash *has not.

no need to use grep if using awk. awk does the job of grep and with more flexibility as its a programming language by itself, not just used for one liners


ls -l | awk '$3==ishan'

just look of $3 or $4 == ishan


ls -l |awk '$3=="ishan" || $4=="ishan"'