Question

for ex :

grep -R "requests" /some/really/long/path/to/type/out

I would like to do something like this

grep -R "requests" (pwd)

Basically, using the output of pwd sorta like a pipe (pipe dosent do it).

Était-ce utile?

La solution

Use command substitution:

grep -R "requests" $(pwd)

The output of the command in $(...) is used as an argument list to the command. If you want the output to be treated as one word, wrap it in double quotes:

ls "$( command-that-produces-dirname-containing-whitespace )"

Autres conseils

In bash you can use backtics for this:

grep -R "requests" `pwd`

pwd will be executed and the stdout of pwd will be used as the third parameter of the grep command

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top