Frage

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).

War es hilfreich?

Lösung

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 )"

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top