replace '"|\n" with new line in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting replace '"|\n" with new line in shell script
# 1  
Old 08-28-2008
replace '"|\n" with new line in shell script

Hi All,

How can i replace '"|\n" with new line in shell script?

Thanks!

vaskar
# 2  
Old 08-28-2008
you can use sed for it..
but with what you wanna replace |\n??
# 3  
Old 08-28-2008
try this:

Code:
echo "|\n" | tr '|\n' '\n'

# 4  
Old 08-28-2008
vidya#>sed 's/\|
>/
>/g' filename
# 5  
Old 08-28-2008
Hi,

I have a file like these format

733961132847|COM|0|0|BD|R|79.95

733961134346|COM|0|0|BD|R|34.95

807280134490|COM|0|0|BD|R|39.99

794051400123|COM|36|0|BD|R|99.98

794051415622|COM|5|0|BD|R|28.99

883929004676|COM|10|0|BD|R|28.99

883929017164|COM|5|0|BD|R|39.99

883929024087|COM|3|0|BD|R|99.98

883929026050|COM|8|0|BD|R|39.99

883929026340|COM|3|0|BD|R|179.98

but i have to make it like the format

733961132847|COM|0|0|BD|R|79.95|

733961134346|COM|0|0|BD|R|34.95|

807280134490|COM|0|0|BD|R|39.99|

794051400123|COM|36|0|BD|R|99.98
|
794051415622|COM|5|0|BD|R|28.99|

883929004676|COM|10|0|BD|R|28.99
|
883929017164|COM|5|0|BD|R|39.99|

883929024087|COM|3|0|BD|R|99.98|

883929026050|COM|8|0|BD|R|39.99|

883929026340|COM|3|0|BD|R|179.98|

pls help me.
# 6  
Old 08-28-2008
Quote:
Originally Posted by vaskarbasak
Hi,

I have a file like these format

733961132847|COM|0|0|BD|R|79.95

733961134346|COM|0|0|BD|R|34.95

807280134490|COM|0|0|BD|R|39.99

794051400123|COM|36|0|BD|R|99.98

794051415622|COM|5|0|BD|R|28.99

883929004676|COM|10|0|BD|R|28.99

883929017164|COM|5|0|BD|R|39.99

883929024087|COM|3|0|BD|R|99.98

883929026050|COM|8|0|BD|R|39.99

883929026340|COM|3|0|BD|R|179.98

but i have to make it like the format

733961132847|COM|0|0|BD|R|79.95|

733961134346|COM|0|0|BD|R|34.95|

807280134490|COM|0|0|BD|R|39.99|

794051400123|COM|36|0|BD|R|99.98
|
794051415622|COM|5|0|BD|R|28.99|

883929004676|COM|10|0|BD|R|28.99
|
883929017164|COM|5|0|BD|R|39.99|

883929024087|COM|3|0|BD|R|99.98|

883929026050|COM|8|0|BD|R|39.99|

883929026340|COM|3|0|BD|R|179.98|

pls help me.
do you wanna add "|" at the end of each line or whats the criteria??
# 7  
Old 08-28-2008
add "|" at the end of each line...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies

3. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

4. Shell Programming and Scripting

Move a line containg "char" above line containing "xchar"

Okay, so I have a rather large text file and will have to process many more and this will save me hours of work. I'm not very good at scripting, so bear with me please. Working on Linux RHEL I've been able to filter and edit and clean up using sed, but I have a problem with moving lines. ... (9 Replies)
Discussion started by: rex007can
9 Replies

5. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Shell Script to identify the line number containing a particular "string"

Hi, I have a log file, where i am required to identify the line number, where a particular string/line appears in the log file. And then copy 200 lines above that line number to a new file. Can someone provide pointers on how to write this script or what command to be used ? Any... (2 Replies)
Discussion started by: kk2202
2 Replies

8. AIX

"too big" and "not enough memory" errors in shell script

Hi, This is odd, however here goes. There are several shell scripts that run in our production environment AIX 595 LPAR m/c, which has sufficient memory 14GB (physical memory) and horsepower 5CPUs. However from time to time we get the following errors in these shell scripts. The time when these... (11 Replies)
Discussion started by: jerardfjay
11 Replies

9. UNIX for Dummies Questions & Answers

shell script to replace a line contain an unkown pattern starting with "aaa, bbb"

Hello, can any one help me on this? I have a /etc/exports file, it may contain a line (I can not remember exactly). Let me use an a sample file myfile.txt which contains a line * mypattern uncertain key words I want this line (with any possible combination of the uncertain key words to be... (2 Replies)
Discussion started by: Dingrong
2 Replies

10. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question