Hi
I have a large text file and I want to split its content into multiple flies.
this large file contains several blocks of codes separated by a comment line for each block.
this comment line represents a directory path
So, when separate these blocks each into a separate file, This output file should be in the same name and directory of its block comment.
an example of the large file content is:
The result will be 2 files:
note1.txt file is created in the path //home/user/app1/lib
and
note2.txt file is created in the path //home/user/app1/core
and so on
Kindly, can you help in writing such a script
Thank you
Last edited by jim mcnamara; 06-19-2012 at 05:13 PM..
---------- Post updated at 02:39 AM ---------- Previous update was at 12:33 AM ----------
I manage to make it work , only when I remove the // from the first line of the large file and keep the subsequent //home/xxxx directory path entries
However, when a block does contain another comment (it is also // but not the //home/xxx directory path), it will cut that file and wont create the blocked file fully. i.e it will crate the block file but not complete!
What I need is to create separate files from the large file , while each block is identified by the full path of the directory:
//home/user/app1/lib/note1.txt
Here is an example of the original file (I will call it x1) that I want to split it into multiple text files (t1.txt, t2.txt and t3.txt) in the directory /home/turki/Downloads/widd (which is already exist)
this is the content of the original file x1
When I use the command:
it does split the content of the x1 file into 3 files t1.txt, t2.txt and t3.txt each in its specified location (inside the "widd" directory)
However, the problem is that if the section of the file contains a comment (like in t1.txt section //some comment here) the split of that file stops there and does not show the whole content of t1 section in the t1.txt file. But I have no problem with t2 and t3 as the content for t2 and t3 does the perfect job of copying the whole content to their appropriate txt files.
How can I split the content of the t1 section EVEN with the comment inside it to the new t1.txt file?
I am trying to write a script that cycles through a folder containing many folders and when inside each one it's supposed to copy all the .fna.gz files to a folder elsewhere if the file and the respective folder have the same name.
for fldr in /home/playground/genomes/* ; do
find .... (8 Replies)
Hi All,
we have a requirement to split a content in a text file every 5 rows and write in a new file .
conditions:
if 5th line falls between center of the statement . it should look upto after ";"
files are below format:
1 UPDATE TABLE TEST1 SET VALUE ='AFDASDFAS'
2 WHERE... (3 Replies)
Dear Experts
my scenario is as follows...
I have one source folder "Source" and 2 target folders "Target_123456" & "Target_789101". I have 2 series of files. 123456 series and 789101 series. Each series has got 3 types of fiels "Debit", "Refund", "Claims".
All files are getting... (17 Replies)
I have a directory that is in the below order (the --- is not part of the directory tree, only there to help illustrate:
DATE --- main level
Folder1 --- level under DATE
plugin_out --- level under Folder1
variantCaller_out.40 --- level under plugin_out
001,002,003 --- level under... (3 Replies)
Hello,
I'm using Windows 7 ; sed, awk and gnuwin32 are installed.
I have a big text file I need to manipulate.
In short, I will have to split it in thousands of short files, then rename and save in a folder which name is based upon filename.
Here is a snippet of my big input.txt file (this... (4 Replies)
Hi,
I am having two folders where i need to compare the content of files and also to know if any new files been added and redirect the difference output in respective filename logs. For e.g.:
Directory D1:
f1
f2
f3
Directory D2:
f1
f2
f3
f4
i Need to compare the directories... (25 Replies)
Dear All,
I have the following file tabulated:
ID distanceTSS score
8434 571269 10
10122 393912 9
7652 6 10
4863 1451 9
8419 39 2
9363 564 21
9333 7714 22
9638 8334 9
1638 1231 11
10701 918 1000
6587 32056 111
What I would like to do is the following, create 100 new files based... (5 Replies)
Arun kumar something somehting Enterting in to the line
.
.
.
.
Some text text Finshing the sentence
Some other text
.
.
.
.
Again something somehting Enterting in to the line
.
.
.
.
.
.
Again text text Finshing the sentence (6 Replies)
Hi All;
I have input file like below
name char(3)
number number(3)
inputfile
namenumber
xyz123abc509kai330
aca203
ald390afa000als303
I wanted to split like below:-
output like this:-
xyz123
abc509
kai330
aca203
ald390 (6 Replies)
Hi,
I have a file which contains records of data.
I need to split the file into multiple files depending upon the value of last field.
How do i read the last field of each record in the file???
Regards,
Chaitrali (4 Replies)