Hi All,
silly question that I'm sure is easy to answer for a more experienced coder...
I have a file called test.txt containing the following text...
need, to, break, this, line, into, individual, lines
using sed, I'd like to make the file look like this...
need
to
break
this
line
into
individual
lines
here's the code I've tried
#!/bin/ksh
sed "s/,/\n/" test.txt > test.new.txt
but it returns the following in test.new.txt
Addn this, line, after, every, line, with, WORD
so, my questions are...
1.) how can I make sed replace all instances of "," in a given line?
2.) how can I make sed insert newline characters instead of just the character n?
Thanks in advance!
the basic algorithm/steps to do this, is to split the line on "," and then print them out with newline
Hi everyone,
Since the previous time I received help from unix.com I have been encouraged to learn more.
going through 1 of the articles(View Article) on sed I found, it pointed an interesting situation.
Suppose the text is :
Romeo and Ethel the Dancer Moves Audience to Tears.
I... (3 Replies)
Hi All,
i have a file test.txt as shown below,
1,test,test111
2,rest,rest222
i want to replace the commas by tab delimiter..,
it should be like,
1 test test111
2 rest rest222
i tried the following code,
sed 's/,/\\t/g' test.txt >> ouptut.txt (9 Replies)
Guyz
I have been using tr command to replace symbol.
I would like to add a symbol to all newlines in a textfile with out replacing them
input
\n (i mean new line)
a
\n
b
\n
c
output
>
a
>
b
>
c (0 Replies)
Hi,
How can I replace the 6th comma on each line (of a csv) with a space?
Any online tutorials with plenty of examples using sed would be very useful.
Alex (2 Replies)
I have a huge file
which is pipe delimiter and i want to replace the pipe delimiter to a comma
Please Help as its v urgent.
Ex: parent|child|alias|....Heading of the file...and the data is of similar structure. (4 Replies)
Hi all,
This my requirement is to spilt the comma's into new line
my sample is
Name,india,ID,cost,Date,vadaloreOffset,neyveliCurveUnit,Riskcuddalore
,,,,,,,,,,,1,0.00576652,,,,,,,,,,,7,0.00625467,,,,,,,,,,,30,0.00832759,,,,,,,,,,,61,0.00977132
expected output to be like this... (2 Replies)
I have the following text as an input text:
input.txt
Results('Toilet', 'Sink', )
and i want to remove the last comma so the output is
output.txt
Results('Toilet', 'Sink' )
I tried using the following sed command, but I get a parsing error:
sed s/, \)/\)/g input.txt >... (5 Replies)
hi
i have a requirement to replace a string with another using sed and to get the result newline separated but after sed replacement the newline vanishes
below is sample code
#!/bin/ksh
set -x
string="name sam\nage 45 \nsport soccer"
echo $string
string=`echo $string | sed... (2 Replies)