The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 06-13-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
awk '{print > substr($0,length-4,2) "_" substr($0,length-2) ".txt"}' infile
Reply With Quote
Forum Sponsor
  #9  
Old 06-13-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by Ygor
awk '{print > substr($0,length-4,2) "_" substr($0,length-2) ".txt"}' infile
Shouldn't it be
awk '{print $0 >> substr($0,length-4,2) "_" substr($0,length-2) ".txt"}' infile

Vino
Reply With Quote
  #10  
Old 06-13-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
No it shouldn't.
Reply With Quote
  #11  
Old 06-13-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
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
Reply With Quote
  #12  
Old 06-14-2005
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,249
See Printing.
Reply With Quote
  #13  
Old 06-14-2005
Registered User
 

Join Date: Jun 2005
Posts: 3
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0