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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

output format

Status
Not open for further replies.

Gloups

IS-IT--Management
Sep 16, 2003
394
FR
HI all, i'm sure this will be very easy for scripts experts.

I send a command wich reports things like:

U787A.001.DPM037W-P1-T7,osiris,Universal Serial Bus UHC Spec
U787A.001.DPM037W-P1-C4,osiris,PCI 1Gbps Ethernet UTP
U787A.001.DPM037W-P1-T12,osiris,Other Mass Storage Controller
U787A.001.DPM037W-P1-T10,osiris,Storage controller
U787A.001.DPM037W-P1-C3,osiris,PCI 10/100Mbps Ethernet w/ IPSec


But when i send the same command in a shell script to send the result in a file, i get the result on a single line. I tried different ways using for example a loop to get each result and send it to the output file but space carracters are interpreted as \n

Then, what should i do do to get the result in the ouput file exactly like when i send the command in interactive mode ?

 
What is the endOfLine character(s) sent by your command ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
How may i get the EOL character used by the command ?


When i tried with a loop i did something like:

for i in `my command`
do
echo $i>>my_ouput_file
done

With this way to do the result is:

U787A.001.DPM037W-P1-T7,osiris,Universal
Serial
Bus
UHC
Spec
U787A.001.DPM037W-P1-C4,osiris,PCI
1Gbps
Ethernet
UTP
U787A.001.DPM037W-P1-T12,osiris,Other
Mass
Storage
Controller
U787A.001.DPM037W-P1-T10,osiris,Storage
controller
U787A.001.DPM037W-P1-C3,osiris,PCI
10/100Mbps
Ethernet
w/
IPSec
 
What about this ?
your command > my_ouput_file
Or this ?
my_ouput_file | while read i
do echo "$i"
done > my_ouput_file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
trying those ways i get the same reslut i've got with my loop, the command output resides in a single line.

Assuming the text wich ends each line contain space caracters, i cant cut the line using -d ' '

I also have to get the result not depending of the ouput type

For example i cant sai all the line are beginig with the 'U' caracter then i'll cut before it
 
Try:
your_command | sed -e s/U78/\\nU78/g > output_file

"If you always do what you've always done, you will always be where you've always been."
 
That's exactly what i've done for the moment but in this case, i have to assume all my lines will begin with U78.

That's not very clean
 
try this:
your_command | cat -ve

or this:
cat -ve your_output_file

This will show if there are any mysterious nonprintable characters.
(E.g. the EOL character mentioned by PHV)

Hope this helps
 
True.
I cannot seen to recreate this on AIX (ksh - vt100) or Linux (bash - xterm).
Which shell and TERM are you using?


"If you always do what you've always done, you will always be where you've always been."
 
I'm in ksh on an xterm with the power 5 HMC
 
Strange...

I tried lsdev -Cc adapter > adapter.lst on the HMC's vterm.
Worked fine. (even if I mail the output)
Do all commands that return a list do the same thing?


"If you always do what you've always done, you will always be where you've always been."
 
lsdev on the power hmc ?? Strange, the HMC is a linux.

the commands i use are partitions management commands like lshwres
 
To discover the EOL: man od

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The vterm session was on the AIX LPAR


"If you always do what you've always done, you will always be where you've always been."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top