A sed command works most of the time however it fails sometimes.
I put each line (record) I read of a file through the following command
data=$(cat file | sed 's/[^a-zA-Z0-9+_:-]//g' | sed 's|.*ex:Msg\(.*\)ex:Msg.*|\1|' )
When I run the script I get a message that states that there is an invalid format character.
The list of invalid chracters I am getting is as below, is there a way to solve this issue?. How can I get rid of the ` character from the input data?
I am afraid its not the first character, I have specified the message that is displayed on the screen when I run my script which is of the format ./records.sh invalid chracters....etc
cfajohnson, unfortunately I cannot post a copy of the data because I am not allowed, confidential info. The only reason I know that these chars are causing a problem is because I get an on line message: ./counter.sh line 5: printf: `w: invalid format and this is repeated for characters that I have mentioned in my initial posting. The contents of counter.sh is:
counter=1
while read line
do
# Test the file
printf "$line" > temp$counter
pref=$(sed <$temp$counter -e 's/[^a-zA-Z0-9+_:-]//g' -e 's|.*ex:Msg\(.*\)ex:Msg.*|\1|')
printf"
let counter=counter+1
done < temp01
Also you mention that I could use only one command instead of three for extarcting the data. Could you please specify? I am new to scripting so any help would be greatly appreciated.
Code:
data=$( sed -e 's/[^a-zA-Z0-9+_:-]//g' -e 's|.*ex:Msg\(.*\)ex:Msg.*|\1|' file )