04-14-2005
Issue with sed in script
I have a loop in a script that is given me an error but, when I do it on the command line it works perfectly. The sed statement has to use the variables from a file so the file is partitioned correctly. I am running on HP:
<Begin error>:
+ cat /u01/bteam/CNAM/1121/.partition
+ read line
+ + echo /^00/p;/^01/p;/^02/p;/^03/p;/^04/p;/^05/p;/^06/p;/^07/p,CWDA
+ cut -d, -f1
part=/^00/p;/^01/p;/^02/p;/^03/p;/^04/p;/^05/p;/^06/p;/^07/p
+ + echo /^00/p;/^01/p;/^02/p;/^03/p;/^04/p;/^05/p;/^06/p;/^07/p,CWDA
+ cut -d, -f2
+ date +%m%d
outfile=/u01/bteam/CNAM/1121/outgoing/CWDA0414
+ sed -n '/^00/p;/^01/p;/^02/p;/^03/p;/^04/p;/^05/p;/^06/p;/^07/p'
+ 0< /u01/bteam/CNAM/1121/lergtemp/LERGT
sed: '/^00/p;/^01/p;/^02/p;/^03/p;/^04/p;/^05/p;/^06/p;/^07/p' is not a recognized function.
+ sort -y
+ tr -d \n\r
+ 1> /u01/bteam/CNAM/1121/outgoing/CWDA0414
+ rm /var/tmp/*
<End Error>
<Begin Code>
cat /u01/bteam/CNAM/1121/.partition | while read line
do
part=`echo $line |cut -d, -f1`
outfile=$opath`echo $line | cut -d, -f2``date +%m%d`
sed -n "'$part'" < $tempfile | sort -y | tr -d "\n\r" > $outfile
rm /var/tmp/*
done
<End Code>
File Contents:
/^00/p;/^01/p;/^02/p;/^03/p;/^04/p;/^05/p;/^06/p;/^07/p,CWDA
/^08/p;/^09/p;/^10/p;/^11/p;/^12/p;/^13/p;/^14/p;/^15/p,CWDB
/^16/p;/^17/p;/^18/p;/^19/p;/^20/p;/^21/p;/^22/p;/^23/p,CWDC
/^24/p;/^25/p;/^26/p;/^27/p;/^28/p;/^29/p;/^30/p;/^31/p;/^32/p,CWDD
/^33/p;/^34/p;/^35/p;/^36/p;/^37/p;/^38/p;/^39/p;/^40/p,CWDE
/^41/p;/^42/p;/^43/p;/^44/p;/^45/p;/^46/p;/^47/p;/^48/p,CWDF
/^49/p;/^50/p;/^51/p;/^52/p;/^53/p;/^54/p;/^55/p;/^56/p,CWDG
/^57/p;/^58/p;/^59/p;/^60/p;/^61/p;/^62/p;/^63/p;/^64/p;/^65/p,CWDH
/^66/p;/^67/p;/^68/p;/^69/p;/^70/p;/^71/p;/^72/p;/^73/p,CWDI
/^74/p;/^75/p;/^76/p;/^77/p;/^78/p;/^79/p;/^80/p;/^81/p,CWDJ
/^82/p;/^83/p;/^84/p;/^85/p;/^86/p;/^87/p;/^88/p;/^89/p;/^90/p,CWDK
/^91/p;/^92/p;/^93/p;/^94/p;/^95/p;/^96/p;/^97/p;/^98/p;/^99/p,CWDL
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Execution of the following segment is giving the error -
Script extract:-
OUT=$DATADIR/sol_rsult_orphn.bcp
TMP1=${OUT}_tmp1
TMP=${OUT}_tmp
( isql -w 400 $dbConnect_OPR <<EOF
select convert(char(10), s.lead_id)
+'|'
+ s.pho_loc_type,
";",
s.sol_rsult_cmnt,
";",
+'|'+ s.del_ind... (3 Replies)
Discussion started by: kzmatam
3 Replies
2. Shell Programming and Scripting
Can someone help me "port" this to AIX sed?
sed '/nas/{n;s/true/false/}'
I know it doesn't like the ; but i don't know how else to do it.... never had to sed on an AIX box :D (7 Replies)
Discussion started by: DeviousPete
7 Replies
3. Shell Programming and Scripting
Hi All
I'm getting this error while executing a sed script
sed: 0602-404 Function /</ i\ File from New Cube: cannot be parsed.
sed "/</ i\ File from New Cube:
/>/ i\ File from Old Cube:" difference1.txt > Difference.txt
I've a file like this
< Y2008 Dec ..... .... ... 345
I want... (6 Replies)
Discussion started by: Celvin VK
6 Replies
4. Shell Programming and Scripting
hi
i have following sed command
this replaces "** in filename1 with octal value 007 filename2
when i put it in script it wont work but it works from command line
my OS is sun OS
---------- Post updated at 06:38 PM ---------- Previous update was at 06:14 PM ----------
i... (10 Replies)
Discussion started by: er_zeeshan05
10 Replies
5. Shell Programming and Scripting
Hi,
I'm developing my first bash script and have made good progress but stuck at this point.
I've run sed on a text file to extract some data and have saved it into a variable e.g.
$blah
the variable contains emails as follows e.g. <a@b.com> <b@c.com>
I'm now trying to edit... (2 Replies)
Discussion started by: newb1000
2 Replies
6. Shell Programming and Scripting
Hi guys. Can somone advise as to what the problem is with the following sed command?
1) read -p "Please enter new username you wish to replace old: " new_username
sed "s/$username/$new_username/" information_file
;;
This is one of the case statements included but I'm... (1 Reply)
Discussion started by: jjb1989
1 Replies
7. Shell Programming and Scripting
I can't get this code to work, could I get some help...
sed -i '' "s:${shLogpath1}${cell}:${shLogpath2}${cell}:g" test.txt
Any Ideas, I think I need to separate the variables some how? (2 Replies)
Discussion started by: digitalviking
2 Replies
8. Shell Programming and Scripting
I have this script to parse some logs:
#!/bin/bash
id=$1
shift
sed "/(id=$id)/,/^$/!d" "$@"
Usage: ./script.sh 1234 logfile
The logs have an empty line before the logged events/timestamps -- most of the time. And this is my issue, since when there is no empty line, it will catch things... (4 Replies)
Discussion started by: KidCactus
4 Replies
9. Shell Programming and Scripting
I'm trying to change a date in a couple of large files using SED. The problem is when I use the -n parameter, it doesn't actually change the file. When I leave out the -n, it sends the whole file to the screen, but it does appear to change it.
The problem is, these files are very large and it... (8 Replies)
Discussion started by: Drenhead
8 Replies
10. Shell Programming and Scripting
Hi,
I am using sed command to extract data from my log file for a certain time interval. From and To "time" are my input arguments.
Now if i use the sed command on command line. I get the desired results and If i use it in script.It fails.
sed command as command line:
sed -n '/04-Mar-2015... (6 Replies)
Discussion started by: oberoi1403
6 Replies