kshuser
October 23, 2009, 12:30pm
1
I have a file file1.dat with the following lines
22885068900000652 B86860003OLFXXX592123320081227
22885068900000652 B86860003ODL-Sp592123420081227
22885068900000652-B94030001ODL-Ch592123520081227
23666483030000653-B94030001ODL-Ch000000120081227
23797049900000654-E71060001OLFXXX000000220081227
23699281320000655 E71060002OLFXXX000000320081227
i want to get the output from the above file file1.dat what is the syntax for this.
22885068900000652+B86860003OLFXXX592123320081227
22885068900000652+B86860003ODL-Sp592123420081227
22885068900000652-B94030001ODL-Ch592123520081227
23666483030000653-B94030001ODL-Ch000000120081227
23797049900000654-E71060001OLFXXX000000220081227
23699281320000655+E71060002OLFXXX000000320081227
can someone help me on this.
run sed command
sed 's/ /+/g' file.dat
---------- Post updated at 08:50 AM ---------- Previous update was at 08:49 AM ----------
output:
user@net:~$ sed 's/ /+/g' file
22885068900000652+B86860003OLFXXX592123320081227
22885068900000652+B86860003ODL-Sp592123420081227
22885068900000652-B94030001ODL-Ch592123520081227
23666483030000653-B94030001ODL-Ch000000120081227
23797049900000654-E71060001OLFXXX000000220081227
23699281320000655+E71060002OLFXXX000000320081227
user@net:~$
right now i am using this way but i am getting only the 3 rows which replaces the space to + but then why i am not getting the existing negative rows in the file.dat file
grep ' ' $DATADIR/file.dat|sed s/\ /\+/g > $DATADIR/out_file.txt
22885068900000652+B86860003OLFXXX592123320081227
22885068900000652+B86860003ODL-Sp592123420081227
23699281320000655+E71060002OLFXXX000000320081227
I want the result with all the rows in the file.
22885068900000652+B86860003OLFXXX592123320081227
22885068900000652+B86860003ODL-Sp592123420081227
22885068900000652-B94030001ODL-Ch592123520081227
23666483030000653-B94030001ODL-Ch000000120081227
23797049900000654-E71060001OLFXXX000000220081227
23699281320000655+E71060002OLFXXX000000320081227
research3:
run sed command
sed 's/ /+/g' file.dat
---------- Post updated at 08:50 AM ---------- Previous update was at 08:49 AM ----------
output:
user@net:~$ sed 's/ /+/g' file
22885068900000652+B86860003OLFXXX592123320081227
22885068900000652+B86860003ODL-Sp592123420081227
22885068900000652-B94030001ODL-Ch592123520081227
23666483030000653-B94030001ODL-Ch000000120081227
23797049900000654-E71060001OLFXXX000000220081227
23699281320000655+E71060002OLFXXX000000320081227
ovis@q45:~$
in my example
sed 's/ /+/g' file > $DATADIR/out_file.txt
the sed command will be replaced all blank characters in all of the rows not only in 3 rows!!
The negative lines will not changed in this case.
Therefore I'm not undertand your issue, the result is the same or I'm wrong?
cat $DATADIR/out_file.txt
22885068900000652+B86860003OLFXXX592123320081227
22885068900000652+B86860003ODL-Sp592123420081227
22885068900000652-B94030001ODL-Ch592123520081227
23666483030000653-B94030001ODL-Ch000000120081227
23797049900000654-E71060001OLFXXX000000220081227
23699281320000655+E71060002OLFXXX000000320081227