Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-12-2003, 03:05 PM   #1
Registered: Apr 2003
Posts: 87

Rep: Reputation: 15
help me help myself

All in bash:

I got the file progress titlebar updater thing to work, but now I want to go a step further:
Have it find what jobs are running, and append their progress to a file, and have that file be constantly updated and outputted. Right now, I'm just working on getting to the directory where the job was run from (in order to check the progress). What I currently have is:

myjobs | grep "bleh" | grep -v -e "blah" | awk '{ print $4 }' | find . -name `head -n 1` -printf %h

What this does is first output the jobs currently set up, one line at a time, then it takes the ones containing "bleh" and removes the lines containing "blah", then grabs the 4th column (which contains file names) and then returns the directory in which the first file in the list is located. What I would like to do now is switch to that directory. I tried doing this:

myjobs | grep "bleh" | grep -v -e "blah" | awk '{ print $4 }' | cd `find . -name `head -n 1` -printf %h`

but it gave these errors:

find: missing argument to `-name'
bash: -printf: command not found
bash: cd: head: No such file or directory

Is there an easier way to do this?

Also - If I am going to get this to work, I need to be able to count the number of rows once "bleh" has been extracted and "blah" has been removed, then be able to repeatedly "sed -e '1d'" to remove the first line and then do the process again (cd to directory, execute other commands to get file progress) until there are no more lines left. Any help with this would also be appreciated, as I just started using linux a few weeks ago.
Old 06-12-2003, 09:27 PM   #2
Registered: Feb 2003
Distribution: Debian
Posts: 797

Rep: Reputation: 30
First of all, can't we put this into a script, instead of one line.
; )

maybe try something like:

for i  in `head -n 1`
  cd `find . -name $i -printf %h`

btw, the problem was in the two sets of quotes.. the shell can't tell where one ends and the next one starts.
ie. you were executing:
cd `find . -name `

check out 'man wc'
maybe 'wc -l' will work for what you want.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:19 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration