![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Spliting file based on condition | Raamc | Shell Programming and Scripting | 2 | 05-15-2008 08:51 AM |
| How to split the String based on condition? | sankar reddy | Shell Programming and Scripting | 2 | 03-19-2008 04:48 AM |
| Moving file to directory based on condition. | ramanagh | Shell Programming and Scripting | 2 | 02-02-2008 08:41 AM |
| Read file based on condition | sbasetty | Shell Programming and Scripting | 5 | 01-31-2007 11:54 PM |
| Splitting a file based on some condition and naming them | srivsn | Shell Programming and Scripting | 1 | 12-07-2005 08:27 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
awk '{print > substr($0,length-4,2) "_" substr($0,length-2) ".txt"}' infile
|
| Forum Sponsor | ||
|
|
|
#9
|
||||
|
||||
|
Quote:
awk '{print $0 >> substr($0,length-4,2) "_" substr($0,length-2) ".txt"}' infile Vino |
|
#10
|
||||
|
||||
|
No it shouldn't.
|
|
#11
|
||||
|
||||
|
Is it that, by default print outputs $0.
And I dont understand by you dont need to append to existing files. Else wouldnt already existing entries be over written ? What am I missing here ? vino |
|
#13
|
|||
|
|||
|
have a look
DATA=`cat input.txt`
for data in $DATA do `echo $data > temp.txt` length=`wc -c temp.txt | tr -s " " | cut -d " " -f 2` prvlength=`expr $length - 5` file_name=`cut -c $prvlength-$length temp.txt` `echo $data >> $file_name.txt` done |
|||
| Google The UNIX and Linux Forums |