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
how to rename multiple files with a single command tayyabq8 Shell Programming and Scripting 5 03-18-2008 12:04 PM
Splitting my program to multiple source files. the_learner High Level Programming 6 06-04-2007 07:53 AM
can you redirect multiple files for input? Matrix_Prime UNIX for Dummies Questions & Answers 4 02-27-2005 03:07 PM
Perform a command to multiple files mcgrawa UNIX for Dummies Questions & Answers 4 09-25-2003 01:40 AM
find files and using them as input arguements for another command bobbygrep UNIX for Dummies Questions & Answers 1 07-18-2001 02:24 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-12-2008
Registered User
 

Join Date: Apr 2008
Posts: 14
Lightbulb Splitting input files into multiple files through AWK command

Hi,

I needs to split *.txt files from single directory depends on the some mutltiple input values. i have wrote the code like below

for file in *.txt
do
grep -i -h "value1|value2" $file > $file;
done.

My requirment is more input values needs to be given in grep; let us say 50 values($value1,$value2.....$value50).
is there any good way of writing the code.

example
aaa 1111 ee3456
bbb 2222 bb7658
kkk 8888 nn1234
hhh 5555 bb4444
lll 9999 ee0987

Also is it possible to split the file starting from 11th position to 15th position;
becaz i want split the file by considering position from the files so that my input values will reduce. like in exapmle(there are repeted values ee bb nn bb ee etc) from the file.

is that can be achived through AWK command?

Thanks in advance.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-13-2008
Registered User
 

Join Date: Apr 2008
Posts: 14
Any suggestios for the above problem?
Reply With Quote
  #3 (permalink)  
Old 05-13-2008
Registered User
 

Join Date: Jul 2006
Posts: 189
HTML Code:
Do you want to split input file according to values?
Reply With Quote
  #4 (permalink)  
Old 05-13-2008
Registered User
 

Join Date: Apr 2008
Posts: 14
yes. I need to split the files according to given input values. Only thing is input values are almost 50. But if consider the position the input values will become less as shown below.

aaa 1111 ee3456
bbb 2222 bb7658
kkk 8888 nn1234
hhh 5555 bb4444
lll 9999 ee0987

if you aboserve the above in 3rd colomn first 2 letters are repeating. so if i consider the position (11th to 15th). i can give only 10 input values.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:58 PM.


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

Content Relevant URLs by vBSEO 3.2.0