Display a specific words from a multiple lines

well, i am so not familiar with this kind of things but i am gonna explain extactly what i am looking for so hopfully someone can figure it out :slight_smile:

i have a command that shows memory usage besides the process name, for example(the command output):

500 kb process_1
600 kb process_2
700 kb process_3
800 kb process_4
700 kb process_5
100 kb process_6

i want to write a script which suppose to show the processes with the desired parameter

for example if the user want the processes with memory usage of 600kb and greater the user should pass 600 as a parameter and this script suppose to show the following :

process_2
process_3
process_4
process_5

the problem is i am so bad with scripting, and i really need this as fast as possible :slight_smile: i would really appreciate if someone could help

Try:

#!/bin/bash
echo "Enter value: "
read x
your_command | awk -vx=$x '$1>=x'
#!/bin/bash 
echo "Enter value: " 
read x 
your_command | awk -vx=$x '$1>=x{print $NF}'

Thanks alot guys :D, i am going to try it tomorrow at work =)))))

i am trying to save the output of the command as a temprory output so i could use it within the script

i have already tried this one but it couldn't work

TEMPDIR=/dir1/dir2
 
final_command> $TEMPDIR/$TEMPFILE
 
rm $TEMPDIR/$TEMPFILE*
 

it keeps saying "cannot write to a directory"