![]() |
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 |
| extracting numbers from strings | gobi | Shell Programming and Scripting | 2 | 05-26-2008 11:44 PM |
| Extracting lines between 2 strings only if the pattern patches | simran | Shell Programming and Scripting | 5 | 04-23-2008 04:58 PM |
| extracting a set of strings from a text file | Deanne | Shell Programming and Scripting | 2 | 09-20-2007 11:31 PM |
| Extracting the lines between 2 strings of a file | babloo | Shell Programming and Scripting | 2 | 02-14-2007 11:27 AM |
| Extracting strings | hugow | UNIX for Dummies Questions & Answers | 1 | 06-24-2005 06:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Help with extracting strings from a file
I want to collect the characters from 1-10 and 20-30 from each line of the file and take them in a file in the following format.Can someone help me with this :
string1,string2 string1,string2 string1,string2 : : : : |
|
||||
|
Quote:
the above script may give other output if we have spaces or blank lines, so better would be to use cut and paste command or the above sed script is again a correct one for your search |
|
||||
|
Quote:
this would solve that, Code:
awk ' { if( length($0) > 0 ) {printf "%s,%s\n", substr($0, 10, 20), substr($0, 20, 30) } }' filename
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|