Creating Multiple data files with spaces in the filename

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating Multiple data files with spaces in the filename
# 1  
Old 03-18-2014
Creating Multiple data files with spaces in the filename


I have a list of filenames in the format with Spaces in the filename.

As an example :

Sample File 1.txt
Sample File 2.txt
Sample File 3.txt.....I have about 100 files like this.

I am trying to create a block of code or use an available command to a) Create a file b) Put in some data in each file.

Suggestions would be much appreciated.
# 2  
Old 03-18-2014
>'any file name you want' works for me. I especially like the directory '. ' when borrowing space! If you put file names or paths in variables, "$dingy_with_spaces" is the trick. They are just spaces, and when quoted lose their whitespace nature.
# 3  
Old 03-18-2014
Not quite sure what you require but perhaps bash shell this example can assist:

for file in "Sample File "{1..100}.txt
    echo "Your age is $((RANDOM % 70))" > "$file"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join multiple files with filename

Please help, I want to join multiple files based on column 1, and put the missing values as 0. Also the colname in the output should say which file the values came from. FILE1 1 11 2 12 3 13 FILE2 2 22 3 23 4 24 FILE3 1 31 3 33 4 34 FILE1 FILE2 FILE3 1 11 0 31 (1 Reply)
Discussion started by: newbie83
1 Replies

2. Shell Programming and Scripting

Insert Filename into Multiple Files

Hi, We have a folder that has files in the following structure abc.sql def.sql efg.sql . . . xyz.sql I have to find a certain string (say "test") in each file and replace it with the name of the file. For eg. if "test" is present in abc.sql, I want to replace it with "test abc". If... (8 Replies)
Discussion started by: jerome_rajan
8 Replies

3. Shell Programming and Scripting

Replace white spaces of multiple files at once

How to rename multiple files by replacing the white spaces with underscore for ex: 293TrexFH\ \ \ GSM855007RINGB_lhb11_binary.txt 293TrexFH\ \ \ GSM855007RINGB_lhb12_binary.txt 293TrexFH\ \ \ GSM855007RINGB_lhb13_binary.txt 293TrexFH_GSM855007RINGB_lhb11_binary.txt... (1 Reply)
Discussion started by: quincyjones
1 Replies

4. Shell Programming and Scripting

Rename all files (filename with spaces) to different extension

Hi, I have files with filenames as below. SGM Daily Sales Email-en-us-05312012.xlwa I want to rename it in .xls. I am writing a script to change this, as there can be multiple files in subfolders. I have the following script. #!/bin/ksh for oldfile in $(find... (1 Reply)
Discussion started by: mac4rfree
1 Replies

5. UNIX for Dummies Questions & Answers

Copying files with spaces in the filename in a for loop

Hi all, I've been tangoing with this one for a couple of days now and I'm still not making any progress. Basically I'm trying to match three numbers in a string from a text file with matching numbers in a jpeg, and then copying the results to another folder. Data looks like this: Model:... (4 Replies)
Discussion started by: faceonline
4 Replies

6. Shell Programming and Scripting

insert filename into each line of multiple files

I need to insert <filename + comma> into each line of multiple files. Any idea how to script that? Regards, Manu (5 Replies)
Discussion started by:
5 Replies

7. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

8. Shell Programming and Scripting

List files with spaces in filename

I have a text file containing files in a directory structure i.e. /project/hr/raw/jcpdatav/datav_aug03 /project/hr/raw/jcpdatav/comb8121sep02n /project/hr/raw/jcpdatav/datav_feb04_ons /project/hr/raw/jcpdatav/corpsick_jun06 /project/hr/raw/jcpdatav/jcpjoiners200507... (3 Replies)
Discussion started by: mr_crosby
3 Replies

9. Shell Programming and Scripting

copying files with spaces in the filename

Hi I am having difficulty copying files from one dir to another due to a space in the names of the file with an extension .rtf There are a group of files and the command am using is cp `ls -rt /wlblive/home/whiops/ops/RTFs/*.rtf|head -20` /wlblive/home/jamshed Since the files are... (3 Replies)
Discussion started by: jamshedj
3 Replies

10. Shell Programming and Scripting

moving files with spaces in filename from one directory to another

Hello, When I run following script #!/bin/bash cd ~/directory1 mv `ls -trF | grep -v / | tail -10 ` ~/directory2 works fine with filenames not having any space but runs into issues with filenames that have spaces tried with $file variable still doesnot work. Can someone help me (4 Replies)
Discussion started by: asakhare
4 Replies
Login or Register to Ask a Question