Inserting newline in front of multi-character string
I'm working with a large file with multiple records, each record begins with ISA[^a-zA-Z0-9]. The issue is, sometimes ISA[^a-zA-Z0-9] is at the start of the line, sometimes it's in the middle of the line. So before I can csplit my main file into multiple records, I have to get each record header onto its own line.
I've been having trouble using sed or tr to do this. Do I have to capture each occurence of ISA[^a-zA-Z0-9] into a variable and then use the variable as part of the regex in a sed statement?
I'm open to all suggestions on how to accomplish this. This is my first time posting, so I apologize if I'm not asking in the forum style or detail.
Thanks!
Note: By ISA[^a-zA-Z0-9] , I'm meaning ISA(+ any non-alphanumeric character) ... in case there's a better way.
Thanks bartus11, this is an example of a record ...
The main file has many of these records. The ~ in this case can be any non-alphanumeric value and that's fine, they can stay. In this case (Hex 1C) needs to be replaced with newline. Throughout the file, the IC can be any non-ascii, non-printable character.
My original thought was to put the value at position 63 into a variable and replace it with a newline with sed but from your code example, I can see there are much better and concise ways to handle substitutions.
I haven't had a chance to experiment with perl and [^[:ascii:]] or [^[rint:]] ... will either work? Is there an entirely different way?
Thanks again for taking time
Last edited by Franklin52; 04-20-2011 at 03:08 AM..
Reason: Please use code tags
I have a file which comes every day and the file data look's as below.
Vi abc.txt
a|b|c|d\n
a|g|h|j\n
Some times we receive the file with only a new line character in the file like
vi abc.txt
\n (8 Replies)
Hello.
I have a string variable named L_TEMP to test a very simple filter.
L_TEMP="50AwL.|KWp9jk"
I want to insert a non printable character between K and W.
I have try this :
linux-g65k:~ # a='50AwL.|K'
linux-g65k:~ # b='Wp9jk'
linux-g65k:~ # L_TEMP="$a$'\x07'$b"
linux-g65k:~ # echo... (6 Replies)
Hi all..
I have a text file which looks like below:
abcd
efgh
ijkl
(blank space)
I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file.
I have tried options like... (14 Replies)
Hello.
I am using :
sed -i -e '/§name_script§/a#'"${MY_TAB11}"'# \
#'"${MY_TAB1}"'The Standard way'"${MY_TAB7}"'# \
#'"${MY_TAB1}"'==============='"${MY_TAB7}"'# \ ' "$CUR_FILE"
Is there a better way to define "MY_TAB7","MY_TAB11" in other way than :
MY_TAB1=$'\t'
MY_TAB2=${MY_TAB1}$'\t'... (2 Replies)
hi,
I want to print the below lines
"Message from bac logistics
The Confirmation File has not been received."
When i give like this in the code
"Message from bac logistics\n The Confirmation File has not been received."
It is giving only
Message from bac logistics\n The... (9 Replies)
Hi , i want to Concatenate a string and use the following code
str="i"
str="$str am \n"
str="$str a \n"
str="$str boy \n"
echo $str
I want to ouput this
i
am
a
boy
However it outputs
i am \n a \n boy \n (3 Replies)
Hi everyon,
I am trying to search for a pattern in a file and add "//" to the begining of the file.
lets say i want to comment out a line from my codes. the line that should be commented out contains the word "reset". i need to search for the word "reset" and comment out that specific line. is... (5 Replies)
i have a file contains like this:
i want to create a script that will insert a comma "." after the 10th character so it would be look like this
thanks in advance (5 Replies)