Multiple file needed with certain file_prefix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple file needed with certain file_prefix
# 1  
Old 05-26-2008
Multiple file needed with certain file_prefix

Hi Guys,

Can I please ask for help? I hv one single file in which contains lines

abc|456|xyx|56475
efg|56758|iew|8938
:
:
:
:
:
zzz|999|fdfj|nnnop

I'm going to break them into small files in which each file contains only single line. And each file should have the prefix as such Mone_<yymmddhhmmss>.vob
# 2  
Old 05-27-2008
What have you tried so far?
# 3  
Old 05-27-2008
Partial solution is:

Code:
$ awk '{print > "file_" NR}' rau.txt

Putting the date format (as you asked) in filename can be done using system, I am also trying, will update if succeed.

//Jadu
# 4  
Old 05-27-2008
this will help you to process one line at a time:
Code:
for line in `cat filename`
do
    echo $line
done

instead of echoing to terminal, write the line in a new file
# 5  
Old 05-27-2008
I think this may work.

typeset -i ln
ln=`cat any | wc -l`
echo $ln
typeset -i n=1
while [ $n -le $ln ]
do
file_nm=`date "+%d%m%G%H%M%S"`
head -$n any | tail -1 > Mone.$file_nm.vob
sleep 1
n=`expr $n + 1`
done

Last edited by siba.s.nayak; 06-04-2008 at 10:19 AM..
# 6  
Old 05-27-2008
Quote:
Originally Posted by siba.s.nayak
I think this may work.

for line in `cat <file name>`
do
file_nm=`date "+%d%m%G%H%M%S"`
echo $line >Mone.$file_nm.vob
done
Hi Siba,

But look pretty strange the file result turns out such, and it only echo what <file name> to final Mone.%file_nm.vob

$ cat Mone_20080527165446.vub
xab
# 7  
Old 05-27-2008
Hi jaduks,

split -l 1 3.unl

ls x?? > file

for x in `cat file`
do

awk '{print > "Mone_$_date.vub" NR}' $x
done


Strange this is Mone_$date.vub1 having the last line
zzz|999|fdfj|nnnop
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep from multiple patterns multiple file multiple output

Hi, I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command. Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns. Xargs -I {} grep... (3 Replies)
Discussion started by: Diya123
3 Replies

2. Shell Programming and Scripting

Grep and replace multiple strings in a file with multiple filenames in a file

Hi, I have a file containing list of strings like i: Pink Yellow Green and I have file having list of file names in a directory j : a b c d Where j contains of a ,b,c,d are as follows a: Pink (3 Replies)
Discussion started by: madabhg
3 Replies

3. UNIX for Dummies Questions & Answers

Help needed in Appending multiple lines

Hello, There is a log file A.log where new lines are getting added every minute. When ever any new lines are getting added in to A , the same lines needs to be appended to B.log I need to append these newly added lines to end of another file B through a shell script. I tried CAT but its... (2 Replies)
Discussion started by: twisterboy
2 Replies

4. Shell Programming and Scripting

help needed with shell script to append to the end of a specific line in a file on multiple servers

Hi Folks, I was given a task to append three IP's at the end of a specific (and unique) line within a file on multiple servers. I was not able to do that with the help of a script. All I could was: for i in server1 server2 server3 server4 do ssh $i done I know 'sed' could be used to... (5 Replies)
Discussion started by: momin
5 Replies

5. Shell Programming and Scripting

Script needed to wait for existence of multiple files

Hi Forum. I need a script to wait for all multiple trigger files to be present or else go to sleep for 10 seconds (Number of trigger files can vary). I tried to search on the forum but was not able to find a solution. I found this code on this forum but it's not working as expected: for... (6 Replies)
Discussion started by: pchang
6 Replies

6. Shell Programming and Scripting

Complex Search/Replace Multiple Files Script Needed

I have a rather complicated search and replace I need to do among several dozen files and over a hundred occurrences. My site is written in PHP and throughout the old code, you will find things like die("Operation Aborted due to....."); For my new design skins for the site, I need to get... (2 Replies)
Discussion started by: UCCCC
2 Replies

7. Shell Programming and Scripting

flexible sed command needed to handle multiple input types

Hello, I need a smart sed command that can take any of the following two as an input and give below mentioned output. As you can see, I am trying to convert some C code INPUT: struct abc_sample1 { char myString; UINT16 myValue1; ... (2 Replies)
Discussion started by: SiftinDotCom
2 Replies

8. Shell Programming and Scripting

Help Needed : Split one big file to multiple files

Hi friends, I have data in flat file as following, first filed is the customer number. We have almost 50-100 customers in the system 100 ABC A123 100 BVC D234 100 BNC N324 200 CBC A122 200 AVC D294 200 HNC N324 300 GBC A173 300 FVC D234 300 DNC N344 I want to split the file and... (5 Replies)
Discussion started by: monicasgupta
5 Replies

9. UNIX for Dummies Questions & Answers

Help needed to sort multiple columns in one file

Hi, I would like to know given that I have 3 columns. Let say I have first 3 columns to do operation and these operation output is printed out each line by line using AWK and associative array.Currently in the output file, I do a sort by -r for the operation output. The problem comes to... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

10. Shell Programming and Scripting

Help needed in processing multiple variables in a single sed command.

Is it possible to process multiple variables in a single sed command? I have the following ksh with three variables and I want to search for all variables which start with "var" inside input.txt. I tired "$var$" but it just prints out everyting in input.txt and does not work. $ more test.ksh... (5 Replies)
Discussion started by: stevefox
5 Replies
Login or Register to Ask a Question