Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split

Status
Not open for further replies.

jimineep

Technical User
May 16, 2006
20
GB
is there a way of splitting standard out/ standard error from a script that falls over, so far I've got:

% ./scratch.pl | split

if you imagine the error was like:

asdf asdf werqwer asdfasf asdasdf

I want a way to split this up by whitespace to become:

asdf
asdf
werqwer
asdfasf
asdasdf


I can do this reasonably simply using perl, but I'm sure there is a quicker way to do it using Cshell...

Cheers
 
man tr

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
cunning, I can turn the \s into \n...

But it still doesnt seem to be working, is it standard error instead of standard out? In which case how do I pipe standard error?
 
2>&1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
csh is |&,
what I would do is:

(./scratch.pl > output) |& tr -s '\040\t' '\n\n'

(tr doesn't support \s, so each whitespace character
needs to be enumerated, here blank and tab. awk
might work better because it is argument based so it suppresses white space.

eugene
 
are these threads moderated ?
can we get rid of these useless "man command" comments??

my common method is one of these:

cat input | tr ' ' '\012'

or

### works for all non-printable characters.
cat input |
sed -e 's/[^ -~]/ /' \
-e 's/ */ /g' |
tr ' ' '\012'
 
quirk,

A lot of people have benefitted from PHV's "man command" statements. They just dont know which command to try ... its like its at the tip of your tongue but you just cant get the command. I have been in such situation. Its useless for some but useful for others.
 
...and I think it's somewhat cheeky to criticise PHV given the help he freely offers, as well as his outstanding record as MVP of the week!

I want to be good, is that not enough?
 
Useless man --- comments???

Even if you don't have man pages on your unix system (because not installed, or whatever), you can google for man pages. Chances are, if you read a man page for basic unix commands for whichever flavour of unix, most command flags and usage explanations will be valid on your unix as well. At least you can try 'em out.

Also, a keyword search in this website/forum may also help you before you need to ask another question, as many unix scripting problems have been addressed before.

PHV's comments' usefulness have been proven time and time again... ;-)


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top