LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-17-2012, 09:19 AM   #16
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0

To be truly honest I have no idea why was it done like that in first place...

May be the idea was/is to capture output + errors all in a single log file , could that justify the intention?

Thanks for your info. Now getting it slowly and steadily
 
Old 03-17-2012, 10:36 AM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,999

Rep: Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190Reputation: 3190
I might have missed something, but to me the obvious answer would be that the following line:
Code:
find . -type f -print | xargs p4 have > outfile
is sending its output to "outfile", obviously, and then the errored information, ie. 'file(s) not on client.', is being sent to stderr??

So is it now not just a choice to either send both to awk or at least stderr?
Code:
find . -type f -print | xargs p4 have |& awk -F"[ /]" '/not on/{print $2}'
 
Old 03-20-2012, 09:40 PM   #18
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@grail the problem is
Code:
find . -type f -print | xargs p4 have > outfile
is not sending error output - file(s) not on client. to outfile but on terminal and that is causing us the grief.

If that would have sent to outfile then extracting file name from outfile and processing it would have been easy task.
Now if I type on command prompt, exactly the way you have given.
Code:
find . -type f -print | xargs p4 have |& awk -F"[ /]" '/not on/{print $2}'
gives me syntax error

Code:
find . -type f -print | xargs p4 have & awk -F"[ /]" '/not on/{print $2}'
keep on hanging until I do Ctl C to come out from loop.

Code:
find . -type f -print | xargs p4 have & awk -F"[ /]" '/not on/{print $2}'
Gives the desired output of error files but only on screen.
If I try to redirect output to a log file there is nothing in logfile...
 
Old 03-20-2012, 09:55 PM   #19
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Has it occurred to you to try
Code:
find . -type f -print | xargs p4 have 2>&1 | awk -F"[ /]" '/not on/{print $2}'
?

It's equivalent to |&, but may not cause the syntax error.

Last edited by Tinkster; 03-20-2012 at 09:58 PM.
 
1 members found this post helpful.
Old 03-20-2012, 10:26 PM   #20
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
Interesting enough! this give output of error files - not on client in 1.log log file.

Code:
find . -type f -print | xargs p4 have 2>&1 | awk -F"[ /]" '/not on/' 2>&1 | tee -a 1.log
Sample output from 1.log is as follows.

Code:
./ahscripts/ccb_backup2/ccb_start.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_test.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_schema_upgrade_oragensec.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_source_release_record.sh - file(s) not on client
I want to extract only name of files so output should give
ccb_start.sh
ccb_test.sh
ccb_schema_upgrade_oragensec.sh
ccb_source_release_record.sh

Seems that we are moving closer
 
Old 03-20-2012, 10:45 PM   #21
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally Posted by sysmicuser View Post
Interesting enough! this give output of error files - not on client in 1.log log file.

Code:
find . -type f -print | xargs p4 have 2>&1 | awk -F"[ /]" '/not on/' 2>&1 | tee -a 1.log
Sample output from 1.log is as follows.

Code:
./ahscripts/ccb_backup2/ccb_start.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_test.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_schema_upgrade_oragensec.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_source_release_record.sh - file(s) not on client
I want to extract only name of files so output should give
ccb_start.sh
ccb_test.sh
ccb_schema_upgrade_oragensec.sh
ccb_source_release_record.sh

Seems that we are moving closer :)
Looking at that all you need to do is to modify your awk statement a little bit to achieve that.

Code:
find . -type f -print | xargs p4 have 2>&1 | awk -F"[ /]" '/not on/{print $4}' 2>&1 | tee -a 1.log
Should do it if my counting wasn't off :)


Cheers,
Tink

Last edited by Tinkster; 03-20-2012 at 11:00 PM. Reason: stripped extra code tag
 
1 members found this post helpful.
Old 03-20-2012, 10:57 PM   #22
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
Thank you !

It works not sure what I was doing before and why it was not working, at some stage I shall go through what I was doing and why it was not working then !

Cheers
 
Old 03-22-2012, 04:57 AM   #23
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@Tinkster

Is it possible to get name of file(I mean full path of file except "- file(s) not on client."

I tried to play around with awk but not much success..

so
Code:
./ahscripts/ccb_backup2/ccb_start.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_test.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_schema_upgrade_oragensec.sh - file(s) not on client.
./ahscripts/ccb_backup2/ccb_source_release_record.sh - file(s) not on client
Should come as
Code:
./ahscripts/ccb_backup2/ccb_start.sh
./ahscripts/ccb_backup2/ccb_test.sh
./ahscripts/ccb_backup2/ccb_schema_upgrade_oragensec.sh
./ahscripts/ccb_backup2/ccb_source_release_record.sh
This would revolutionize the whole process...
 
Old 03-22-2012, 05:34 AM   #24
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Sure. Change the delimiter to "[ -]" instead, and print $1.
 
1 members found this post helpful.
Old 03-22-2012, 05:46 AM   #25
sysmicuser
Member
 
Registered: Mar 2010
Posts: 458

Original Poster
Rep: Reputation: 0
@Tinkster ! Many thanks it works
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Interesting awk files for ns2 mobile simulations unodior Linux - Software 10 05-27-2012 04:11 PM
[SOLVED] call awk from bash script behaves differently to awk from CLI = missing newlines titanium_geek Programming 4 05-26-2011 09:06 PM
[SOLVED] awk: how can I assign value to a shell variable inside awk? quanba Programming 6 03-23-2010 02:18 AM
LXer: Interesting new Ubuntu-derived, OS X-inspired distro, interesting revenue (yes, LXer Syndicated Linux News 0 05-01-2009 08:51 AM
shell command using awk fields inside awk one71 Programming 6 06-26-2008 04:11 PM

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

All times are GMT -5. The time now is 03:26 AM.

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
Open Source Consulting | Domain Registration