![]() |
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 |
| Strange Characters After Using Notepad | dgower2 | Shell Programming and Scripting | 4 | 05-21-2009 12:01 PM |
| How to count lines - ignoring blank lines and commented lines | kthatch | UNIX for Dummies Questions & Answers | 6 | 05-25-2007 02:21 AM |
| Find lines greater than 80 characters in a file | mrgubbala | Shell Programming and Scripting | 8 | 03-11-2007 12:51 AM |
| Split a huge line into multiple 120 characters lines with sed? | jerome_1664 | Shell Programming and Scripting | 2 | 08-17-2006 01:03 PM |
| Strange Characters in Filename | kristy | UNIX for Dummies Questions & Answers | 4 | 03-07-2002 06:38 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Dear All:
I Have a bunch of files which I'd like to process with a shell script. The problem is that the files have strange characters in their headers, like �g�8@L-000-MSG2__-ABCD________-FIRA_____-000001___-200806181330-__ ��e� Data from BLABLABLA, Instrument: BLABLA, Date: 2008/06/18 13:30Z Row: 1078 Col: 1130 Lat: -22.267 Lon: 22.256 *** Something here *** For my intents, I only need the information (in this case) from line 3 onwards. Sometimes this strange header occupies 2 lines, others 3...others...I don't know. I made a very simple test, like FILE=`find . -type f -name "FILENAME"` for i in $FILE do FNOW=`echo $i` #Cuts two first lines of the file sed '1,2d' $FNOW > newfile sed '/^$/d' -i newfile HEADER=`head -1 newfile | cut -c1-4` if [ "$HEADER" != "Data" ] then sed '1d' -i newfile sed '/^$/d' -i newfile fi #A simple testing HEADER2=`head -1 newfile | cut -c1-4` echo ${HEADER2},${HEADER} >> test.txt done The problem is that.....sometimes i don't get to cut all the "strange" headers to obtain "clean" files, as you can see in some lines of test.txt Data,@H Data,ۘ Data,Data Data,@H (etc) So: Is there any way to fulfill my intentions with sed? Maybe some "delete all the first lines until find the expression «Data»? Honestly, i don't know what else to try. Thank you very much in advance |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|