![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can I read a file character by character? | murtaza | Shell Programming and Scripting | 4 | 04-27-2009 05:51 AM |
| Using input file to filter data from another file | tumblez | UNIX for Dummies Questions & Answers | 1 | 07-21-2008 04:21 PM |
| check for a particular character inside a file and substitute with a given character? | karthikprasathk | AIX | 1 | 07-01-2008 03:29 AM |
| Can i read a file character by character | karnan | Shell Programming and Scripting | 6 | 05-19-2008 02:22 AM |
| how to get input from file | ajaya | Shell Programming and Scripting | 1 | 04-05-2006 02:02 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How can I get rid of the ` character from input file?
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? `w' `m' `k' ``' `;' `O' `m' `H' `^' ` ' `:' `v' `S' `k' `j' `)' `!' `[' `m' `@' `T' |
|
||||
|
Sample data
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 ) |
|
|||||
|
Quote:
Quote:
Quote:
Quote:
Quote:
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|