Hi, I'm a bit rusty with my shell scripting and have a need to create a script to do the following:
Search a file for lines beginning with this string:
SITE_LIST_STR_PARM
Then for this line extract each of the numbers following it and put them in a new file each on a different line.
The numbers themselves have this string before them (which I'd like to delete):
"\\\'
with one of these two strings after them:
\\\'",
(which I'd like to replace with a carriage return)
or
\\\'"
(which I'd like to delete)
here's an example of the content of the file:
what I'd like is for a new file to be created from this looking like this:
I've been playing around with the code for some time now and have come up with this:
Which doesn't even parse... Was wondering if anyone could spot where I'm going wrong?
Cheers
Search a file for lines beginning with this string:
SITE_LIST_STR_PARM
Then for this line extract each of the numbers following it and put them in a new file each on a different line.
The numbers themselves have this string before them (which I'd like to delete):
"\\\'
with one of these two strings after them:
\\\'",
(which I'd like to replace with a carriage return)
or
\\\'"
(which I'd like to delete)
here's an example of the content of the file:
Code:
Testline
testline
SITE_LIST_STR_PARM="\\\'3607\\\'","\\\'9158\\\'","\\\'3160\\\'","\\\'2675\\\'"
other test line
what I'd like is for a new file to be created from this looking like this:
Code:
3607
9158
3160
2675
I've been playing around with the code for some time now and have come up with this:
Code:
#!/bin/ksh
sed -e s/SITE_LIST_STR_PARM/s/\\\'",/\n/g -e s/SITE_LIST_STR_PARM/s/"\\\'//g -e s/SITE_LIST_STR_PARM/s/\\\'"//g MyFile1.param > MyFile2.param
Which doesn't even parse... Was wondering if anyone could spot where I'm going wrong?
Cheers