The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Split large file and add header and footer to each file ashish4422 Shell Programming and Scripting 1 04-15-2008 06:12 AM
Split a file with no pattern -- Split, Csplit, Awk madhunk UNIX for Dummies Questions & Answers 10 12-17-2007 12:57 PM
split the file name rinku Shell Programming and Scripting 1 05-28-2007 01:47 AM
How to split file by tags inside file? spookyrtd99 Shell Programming and Scripting 1 07-31-2006 12:50 AM
Split file using awk pvar Shell Programming and Scripting 8 07-21-2004 09:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-31-2006
getdpg getdpg is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 72
Need to split the file

I have a file that has text in the format below

/users/test/krachel/
! Some text
! Some Text
/user/test/limo
! some text
! some text
! Some text
/user/test/krachel
! Some text

How can I seperate the text between a pair of '/users/test/' into seperate files ???

any information would be of great help. Thanks

want to split data like this
File001
/users/test/krachel/
! Some text
! Some Text
File002
/user/test/limo
! some text
! some text
! Some text
  #2 (permalink)  
Old 08-31-2006
getdpg getdpg is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 72
i am facing problem in csplit command please help me

csplit -f outfile. -n 1 inputfile '/users/testsuite/db/' '(*)'

It gives error csplit : /users illegal offset

please help
  #3 (permalink)  
Old 08-31-2006
mbketan mbketan is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 9
one method is to use awk if the pattern position is known.....little lengthy....but works fine....

awk '{
if(substr($0,1,5)=="pattern")
{
fn="outfile" n++
print $0 >> fn
}
else
print $0 >> fn

}' file_name

cheers
  #4 (permalink)  
Old 08-31-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
see if this is right

Code:
csplit -f outfile. inputfile "/\/user\/test\//" {1}
You just needed to escape the "/" - slashes. And specify how many times that pattern needs to be searched - (value inside{})
  #5 (permalink)  
Old 08-31-2006
getdpg getdpg is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 72
it gives error file cant open and another script give error illegal operator
  #6 (permalink)  
Old 08-31-2006
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
be clear

Could you be clear on which one gives what error. Use your own input filenames while executing the commands. And also details of your Unix box will also be helpful sometimes.
  #7 (permalink)  
Old 08-31-2006
getdpg getdpg is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 72
The awk script gives error cant open file
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0