You are not logged in.
Pages: 1
Topic closed
How to change in text file to display each words in one column.
test0 test1 test2 test3
test0
test1
test2
test3
Markku
Offline
if you know then are always space seperated, and all there is is a list needing to be converted into a column..
tr ' ' 'n'
then just pipe the text through it..
cat file | tr ' ' 'n'
There are a myriad of other ways to do it, and coutless others depending on the utilities/programming languages, chosen.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
cat file | tr ' ' 'n'
Thanks!
Markku
Offline
sed "s/s*/n/g" file
might work too... and that will work on any number of whitespaces (tabs, spaces, etc)
Offline
Works too well.
[rasat@localhost /]$ sed "s/s*/n/g" test.tmp
t
e
s
t
t
e
s
t
1
t
e
s
t
2
[rasat@localhost /]$
Markku
Offline
what the? what is "s"? am I backwards... maybe you you want "w"? I dunno... I'll have to bust out my sed reference later...
Offline
you want a plus instead of a star phrakture. Star also matches 0 occurances. Plus is one or more.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
Ahhhh... that's it...
sed "s/s+/n/g" file
Offline
No plus or star does the job.
sed "s/s/n/g"
Markku
Offline
yeah, but that only works for a single whitespace.... try two spaces and you'll get multiple newlines...
Offline
Hi,
These codes have not worked for me, i am unsure why...
My data is in the form..
[lg45@dev64-mgmt ~]$ echo $start
25293633 7393500 10578865 25293623 122206254 26797134 41906484
but i have also tried saving it as a new file 'nano.txt' - either way the sed and "tr '' 'n'" methods give me random results such as
n2n5n2n9n3n6n3n3n and 25293633n7393500n10578865n2...
Any suggestions would be great
Offline
$ tr \ \\n <<<'25293633 7393500 10578865 25293623 122206254 26797134 41906484'
Offline
New forum software probably messed those posts up removing backslashes.
Putting the backslashes back:
echo a b c | tr ' ' '\n'
echo a b c | sed 's/\s\+/\n/g'
Offline
2005-04-14
ooooooooooooooooooold thread
Offline
Offline
Pages: 1
Topic closed