linux - Use bash script $1 argument in awk command -


I want to create a bass script that takes an argument and awk to print Using

This is an orphaned process:

  # find_orphan.sh: ps -elf | Awk '/ $ 1 / & amp;! / Awk / {If ($ 5 == 1) {print $ 15}} ' 

Unfortunately I'm having trouble rendering $ 1 as a bash logic ..

If I run it without using $ 1 then my program will work:

  ps -elf | Awk '/ some_program / & amp;! / Awk / {If ($ 5 == 1) {print $ 15}} ' 

I should really be able to specify the awk search pattern

Shell variables are only expanded inside double quotes (or no citations at all), not a single quote. You can try

  ps -elf | Awk '/' $ 1 '/ & amp; Amp;! / Awk / {if ($ 5 == 1} {print $ 15}} ' 

I think that the anubhavas solution is better, but it is similar to other tools with similar conditions Also works in


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -