Create Multiple files with content


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create Multiple files with content
# 8  
Old 04-30-2013
Quote:
Originally Posted by Prashanth B
Code:
for i in {1..5}
do
cp details.csv details{$i}.csv
done

Code:
for i in 1 2 3 4 5
do
cp details.csv details{$i}.csv
done

regards
# 9  
Old 04-30-2013
Quote:
Originally Posted by Prashanth B
Yeah Its working I thought of getting it in single command rather than executing it 5 times.

Code:
for i in {1..5}
do
cp details.csv details{$i}.csv
done

this is not creating 5 different files rather it creates one file as details{1..5}.csv
I donno where I went wrong..?
What you wrote would probably work with the bash shell. In AIX, though, the Korn shell (ksh) is used. -=Xray=- showed you already how a for-loop in ksh is constructed.

I hope this helps.

bakunin
# 10  
Old 05-01-2013
Maybe that would have worked if you had started ksh93. ksh93 supports some extra syntax that default ksh does not support.

for something like this though I would have done almost the same as you example:

Code:
$ for i in 1 2 3 4 5
do
cp details.csv details{$i}.csv
done

Quote:
Originally Posted by Prashanth B
Yeah Its working I thought of getting it in single command rather than executing it 5 times.

Code:
for i in {1..5}
do
cp details.csv details{$i}.csv
done

this is not creating 5 different files rather it creates one file as details{1..5}.csv
I donno where I went wrong..?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create multiple files

dear all suppose I have two files file_000 and file_id: file_000: blablablabla000blablabla000 000blahblah000blahblah blah000blahblahfile_id: 001 002 003now, based on file_id, I want to create 3 files; the name of each file would be file_001,file_002,file_003,respectively, and the... (4 Replies)
Discussion started by: littlewenwen
4 Replies

2. Shell Programming and Scripting

Create multiple zip files each containing 50 xml files.

Hi, Is there a direct command or need to write a shell script for following requirement? Everyday a folder is populated with approx 25k to 30k xml files. I need to create multiple zip files in the same folder each containing 50 xml files. The last zip file may or may not contain 50 xml files.... (6 Replies)
Discussion started by: Rakesh Thobula
6 Replies

3. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

4. Shell Programming and Scripting

How to create multiple files from one file?

Hi everyone! I usually get large files with different groups of entries; for example, each line starts with A, B, C, D, or E. Is there a way to separate all these entries and then write them in 5 different files with one awk program? Thank you! (4 Replies)
Discussion started by: Avro1986
4 Replies

5. Shell Programming and Scripting

How to create multiple files?

HI, I would like to create the files as file1.txt file2.txt file3.txt ...... ....... ....... filen.txt in a single unix command, i dont want to use the loops. n is user specific Kindly help me in this. THank you Jagadeesh (2 Replies)
Discussion started by: jagguvarma
2 Replies

6. UNIX for Advanced & Expert Users

Create a file based on multiple files

Hey everyone. I am trying to figure out a way to create a file that will be renamed based off of one of multiple files. For example, if I have 3 files (cat.ctl, dog.ctl, and bird.ctl) that gets placed on to an ftp site I want to create a single file called new.cat.ctl, new.dog.ctl, etc for each... (3 Replies)
Discussion started by: coach5779
3 Replies

7. UNIX for Dummies Questions & Answers

Deleting Multiple Files With the Same Content

My website has been hacked and i need to remove a lot of unique files with same content. The files have very similar code: eval(base64_decodeHow do i find multiple/all the files with the above code and remove them? Thanks. (10 Replies)
Discussion started by: Boris_yo
10 Replies

8. Shell Programming and Scripting

renaming multiple files with first line of content

Hi , I want to rename multiple files with their first line bar the first character + the extension .qual. For the example below the filename should read 7180000000987.qual. I have trawled through different threads for 2 days and I don't seem to find anything I can adopt for this task :confused: ... (7 Replies)
Discussion started by: Bruno
7 Replies

9. Shell Programming and Scripting

How to create multiple list of files in a directory ?

Hi, i have say 100 files in a directory. file1.log file2.log file3.log file4.log file5.log file6.log ... ... ... file99.log file100.log ========= I need to create another file which contains the list of al these log files. each file should contain only 10 log file names. it shud... (4 Replies)
Discussion started by: robinbannis
4 Replies
Login or Register to Ask a Question