![]() |
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 |
| Extract the last character of a string | annelisa | Shell Programming and Scripting | 8 | 07-05-2008 12:57 AM |
| Sed-Special character replacement | usshell | Shell Programming and Scripting | 3 | 05-22-2008 11:06 AM |
| how to extract a tilde delimited file in unix | trichyselva | Shell Programming and Scripting | 12 | 03-06-2007 12:19 AM |
| replacing string with special character ??? | imppayel | Shell Programming and Scripting | 4 | 12-08-2004 05:07 AM |
| special character ? | mile1982 | High Level Programming | 1 | 10-19-2004 09:15 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi folks,
None of the solutions did not work. Can someone please help me. My requirement was The file has many lines. In each line, after 3 or 4 characters, there is a special character like *, ~ or + etc. The first 3 or 4 characters can be Alphabet, or Numeric. I wanted to extract the first 3 or 4 characters from each line with out the special character. Thanks, AK. |
|
|||||
|
And..
Code:
awk -F"[*~]" '{print $1}' input.txt
If it didnt work, post the results of the above awk script for a sample section of your input file. Best would be the part of the input file, where the script fails. Vino |
|
||||
|
Thanks Vino for your help
My input file is as below ISA~00~ ~00~ ~ZZ~12345 ~ZZ~54321 GS~SH~12345 ~54321 ST~86~000000007 BSN~00~0958 DTM~011~ET And, when I ran the code above, the below results appeared ISA~00~ ~00~ ~ZZ~12345 ~ZZ~54321 GS~SH~12345 ~54321 ST~86~000000007 BSN~00~0958 DTM~011~ET My requirement is to get the first 2 or 3 characters like ISA, GS, ST, BSN and DTM. In this file, the special character is '~', but in other files it may vary. |
|
||||
|
Thanks Vino for your help
My input file is as below ISA~00~ ~00~ ~ZZ~12345 ~ZZ~54321 GS~SH~12345 ~54321 ST~86~000000007 BSN~00~0958 DTM~011~ET And, when I ran the code above, the below results appeared ISA~00~ ~00~ ~ZZ~12345 ~ZZ~54321 GS~SH~12345 ~54321 ST~86~000000007 BSN~00~0958 DTM~011~ET My requirement is to get the first 2 or 3 characters like ISA, GS, ST, BSN and DTM. In this file, the special character is '~', but in other files it may vary. Thanks, AK |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|