I am hoping someone can help me with a solution to this problem using SED. My issue is actually two-fold. First, I have an order file that is sent to us from another system, however, there has been a change in current processes that requires a carriage return added to the end of each order. The file being sent to us is a .CSV with the orders running into each other as shown below:
The first order ends at PS and the next order begins directly after. The current software is capable of reading this properly. The problem begins with an additional software package that requires there to be a Carriage Return after PS.
My second dilemma is that there are two new fields being added to each order as shown below:
Now there is a 3 at the end of the order. The final output of the information above must look like the format below:
Also keep in mind there may or may not be a Y or even a 3 at the end, leaving data possibly looking like this PS~~. However, the system will know what to do as long as there is a Carriage Return at the end. [FONT=Calibri]The only tip i can think of regarding patterns is there will always be 18 ~ delimiters if that helps with finding a pattern.
I hope I have not confused this and that someone might be able to help me out with this. Thank you for any help you might have as well as your time.
---------- Post updated at 02:44 PM ---------- Previous update was at 12:14 PM ----------
In addition to the pattern I mentioned already, you can basically state that after the 18th ~ delimiter if there is a 3 then add a carriage return after the 3 otherwise add a carriage return after the 18th ~ delimiter.
Last edited by Corona688; 09-17-2012 at 01:59 PM..
This is nearly exactly what we need rdrtx1 thank you. However, for some reason it adds delimiters where they shouldn't be but only in the first line. Otherwise, all other lines are perfect.
Success!! That worked great rdrtx1. Thank you again. 244an I have not tried your solution yet but thank you for responding. I will post again when I try it.
Hi all,
need your help in replacing carriage return in a record.
Input:
col1|col2|col3|col4|col5|col6|col7|col8|col9|col10
1|aa|bb|cc|dd|eee
eee|ff|ggggg|hh
hhh|iii
2|zz|yy|xx|ww|vv|uu|tt|ss|rr
Output:
col1|col2|col3|col4|col5|col6|col7|col8|col9|col10... (12 Replies)
Hi
I am using sed command to make SCORE=somevalue to SCORE=blank in a file.
Please see the attached lastline.txt file. After executing the below command on the file, it removes the last line.
cat lastline.txt | sed 's/SCORE=.*$/SCORE=/g' > newfile.txt
Why does sed command remove the... (3 Replies)
Greetings
I need to replace "whitespace" in a file with the newline character aka carriage return
My command is either wrong or not interpreted properly by me shell
sed s/" "/\\n" "/g nets > nets1
or
sed s/" "/\n" "/g nets > nets1
nets (input file)
13MHZ_IN... (4 Replies)
I want to instert Category:XXXXX into the 2. line
something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong:
sed "2i\\${n}Category:$cat\n"
Sample:
Titel Blahh Blahh abllk sdhsd sjdhf
Blahh Blah Blahh
Blahh
Should look like... (2 Replies)
Hi everybody!
I'm working in one script with sed, I have file with the next content:
<voms.db.type
value="changeme"/>
<voms.db.host
value="changeme"/>
<voms.admin.smtp.host
value="changeme"/>
<voms.mysql.admin.password
value="changeme"/>
<glite.installer.verbose
value="true"/>
... (3 Replies)
Could someone tell me how to do the below without opening the file? (eg in sed or awk)
I have a file with the contenst below:
$ more file1.txt
10
AAA;
200
BBB;
3
CCC;
I want to delete the carriage return of one line above the line which has ";" at the end to get the... (3 Replies)
Hi,
I'm not very familiar with unix shell. I want to replace the combination of two carriage returns and one newline with one carriage return and one newline. I think the best way to do this is to use sed. I tried something like this:
sed -e "s#\#\#g" file.txt
but it doesn't work.
Thanx... (2 Replies)
I have a file with multiple records in it and want to create a single record by removing all the carriage returns, is there a sed command or another command that will easily allow this to happen.
current layout
813209A
813273C
812272B
expected result
813209A813273C812272B
previously I... (3 Replies)
I try to test the carriage return in a variable.
$ LENGTH=`expr $VARIABLE : ".*"` will return the length of the variable. But this doesn't work if $VARIABLE has zero length.
Any help will be well appreciated.
Thanks in advance.
Giovanni (4 Replies)