LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 06-12-2003, 04:05 PM   #1
brian0918
Member
 
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, 10:27 PM   #2
cuckoopint
Member
 
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:

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

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.
 
  


Reply


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



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:44 PM.

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