|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Using SED command in a shell script: Unterminated address regex
Hi All, I am trying to use a sed command in a shell script in order to delete some lines in a file and I got the following error message. I don't understand why it is not working 'cause I have tried with simple quotes, then with double-quotes, and it is not working. sed: -e expression #1, char 4: Unterminated address regex Here below is the code I used in my shell script: 1- First I read a Exclusion file where I retrieve in each line a Pattern 2- Then I use this pattern in sed cmd to delete the corresponding line and put the result in another file Code:
buildGrep()
{
nbl=`cat $exclusionFile | wc -l`
i=1
exclusion=`cat $exclusionFile | tail -${i} | head -1`
exclusions="sed -e /${exclusion}/d"
while [ $i -lt $((nbl+1)) ];
do
exclusions="${exclusions} -e '/${exclusion}/d'"
i=`expr $i + 1`
exclusion=`cat $exclusionFile | tail -${i} | head -1`
done
FinalExclusion=`${exclusions} <${TemporaryFile} >${aFiltered_monerrFile}`
}
aDate=`date '+%y.%m.%d_%H.%M.%S'`
aFiltered_monerrFile=Filtered_File.txt
TemporaryFile=TempFile$aDate.txt
ssh xxxx@xxxxx fgrep "2010\/03\/10" xxxxxxxxxxxxx/OriginalFile > $TemporaryFile
exclusionFile=xxxxx.dat
buildGrepHave somebody any idea ? Thank you in advance, Alpha Last edited by Franklin52; 03-10-2010 at 05:47 AM.. Reason: Please use code tags! |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
If you explain your input and output,it will be better to understand by us.
|
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
What do you mean exactly by input and output ?
|
|
#4
|
|||
|
|||
|
No Idea what you are doing but if you want to use shell variable in sed... Code:
sed '/'"${exclusion}"'/d' infile |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
@malcomex999:
I have tried with the simple-quote/double-quotes, but I still have the same issue: sed: -e expression #1, char 3: Unterminated address regex |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Quote:
Code:
buildGrep()
{
nbl=`cat $exclusionFile | wc -l`
i=1
exclusion=`cat $exclusionFile | tail -${i} | head -1`
exclusions="sed -e /${exclusion}/d"
while [ $i -lt $((nbl+1)) ];
do
exclusions="${exclusions} -e '/${exclusion}/d'"
i=`expr $i + 1`
exclusion=`cat $exclusionFile | tail -${i} | head -1`
done
FinalExclusion=`${exclusions} <${TemporaryFile} >${aFiltered_monerrFile}`
}
aDate=`date '+%y.%m.%d_%H.%M.%S'`
aFiltered_monerrFile=Filtered_File.txt
TemporaryFile=TempFile$aDate.txt
ssh xxxx@xxxxx fgrep "2010\/03\/10" xxxxxxxxxxxxx/OriginalFile > $TemporaryFile
exclusionFile=xxxxx.dat
buildGrepBut i see above, there is no filename to read from for the sed command...(in red) Can you explain what you are trying to achieve? |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Yes, because in this line, I just reteieve on Line from my exclusion file. After that I concatene all the exclusion patterns with my sed command in green. The real call off the sed command is in the blue line with input and output file: Code:
buildGrep()
{
nbl=`cat $exclusionFile | wc -l`
i=1
exclusion=`cat $exclusionFile | tail -${i} | head -1`
exclusions="sed -e /${exclusion}/d"
while [ $i -lt $((nbl+1)) ];
do
exclusions="${exclusions} -e '/${exclusion}/d'"
i=`expr $i + 1`
exclusion=`cat $exclusionFile | tail -${i} | head -1`
done
FinalExclusion=`${exclusions} <${TemporaryFile} >${aFiltered_monerrFile}`
}
aDate=`date '+%y.%m.%d_%H.%M.%S'`
aFiltered_monerrFile=Filtered_File.txt
TemporaryFile=TempFile$aDate.txt
ssh xxxx@xxxxx fgrep "2010\/03\/10" xxxxxxxxxxxxx/OriginalFile > $TemporaryFile
exclusionFile=xxxxx.dat
buildGrep
buildGrep()
{
nbl=`cat $exclusionFile | wc -l`
i=1
exclusion=`cat $exclusionFile | tail -${i} | head -1`
exclusions="sed -e /'"${exclusion}"'/d"
while [ $i -lt $((nbl+1)) ];
do
exclusions="${exclusions} -e '/${exclusion}/d'"
i=`expr $i + 1`
exclusion=`cat $exclusionFile | tail -${i} | head -1`
done
FinalExclusion=`${exclusions} <${TemporaryFile} >${aFiltered_monerrFile}`
}
aDate=`date '+%y.%m.%d_%H.%M.%S'`
aFiltered_monerrFile=Filtered_File.txt
TemporaryFile=TempFile$aDate.txt
ssh xxxx@xxxxx fgrep "2010\/03\/10" xxxxxxxxxxxxx/OriginalFile > $TemporaryFile
exclusionFile=xxxxx.dat
buildGrep |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regex to match IP address | glev2005 | UNIX for Advanced & Expert Users | 5 | 03-06-2010 07:03 AM |
| Shell script regex help: accept only 3 file extensions | grep01 | Shell Programming and Scripting | 9 | 11-13-2009 12:30 AM |
| Checking the password thru Regex via Shell Script | gudikal_karanam | Shell Programming and Scripting | 1 | 09-18-2009 11:57 AM |
| regex/shell script to Parse through XML Records | Jerrad | Shell Programming and Scripting | 5 | 06-12-2009 05:59 PM |
| EMail Address Validation (Shell Script) | balajiora | Shell Programming and Scripting | 3 | 05-20-2009 03:41 PM |
|
|