Create files with one command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create files with one command
# 1  
Old 10-09-2007
Create files with one command

I whant a create some files in the certain range.
For example, begin 8811 and finishing 8878
I know one good decision
Code:
touch 88{11,12,13,14,15,16,...,...,78}

I try touch 88[11-78], but i don't have results Smilie Bash create file with name 88[11-78] Smilie
But it very long command Smilie I wanna create it easy
This is possible ?
# 2  
Old 10-09-2007
Just try with looping... eg. as below, it will help to create file from 8811 to 8878. Hope this will help...

i=11
while [ i -lt 79 ];do
touch 88$i
i=`expr $i + 1`
done
# 3  
Old 10-09-2007
Quote:
Originally Posted by timontt
Just try with looping... eg. as below, it will help to create file from 8811 to 8878. Hope this will help...

i=11
while [$ i -lt 79 ];do
touch 88$i
i=`expr $i + 1`
done
only a little typo.... Smilie
# 4  
Old 10-09-2007
Good catch... DukeNuke2. Thanks! Smilie
# 5  
Old 10-09-2007
Quote:
Originally Posted by jess_t03
I whant a create some files in the certain range.
For example, begin 8811 and finishing 8878
I know one good decision
Code:
touch 88{11,12,13,14,15,16,...,...,78}

I try touch 88[11-78], but i don't have results Smilie Bash create file with name 88[11-78] Smilie
But it very long command Smilie I wanna create it easy
This is possible ?
bash, zsh, ksh93:

Code:
touch {8811..8878}

# 6  
Old 10-09-2007
Quote:
Originally Posted by radoulov
bash, zsh, ksh93:

Code:
touch {8811..8878}

nice one! but it only works in zsh for me... not in bash or ksh. but anyway, a really nice one Smilie
# 7  
Old 10-09-2007
Quote:
Originally Posted by DukeNuke2
nice one! but it only works in zsh for me... not in bash or ksh. but anyway, a really nice one Smilie
Yes,
it depends on your bash/ksh version:

Code:
zsh 4.3.4% bash
bash 3.2.25(1)$ echo {1..3}
1 2 3
bash 3.2.25(1)$ ksh
$ print ${.sh.version}
Version M 1993-12-28 r
$ echo {1..3}
1 2 3
$ mksh
$ print $KSH_VERSION
@(#)MIRBSD KSH R29 2007/05/24
$ echo {1..3}
{1..3}
$ pdksh
$ echo {1..3}
{1..3}

In some shells the brace expansion generates letters (and other characters) too:

Code:
zsh 4.3.4% print {a-c}
{a-c}
zsh 4.3.4% setopt braceccl
zsh 4.3.4% print {a-c}    
a b c
zsh 4.3.4% bash
bash 3.2.25(1)$ echo {a..c}
a b c
bash 3.2.25(1)$ ksh
$ echo {a..c}    
a b c

Code:
zsh 4.3.4% print {a--z}
. / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z
zsh 4.3.4% bash+william 
bash 3.00.0(2)-bashdiff-1.44$ echo {a--z}
a b c d e f g h i j k l m n o p q r s t u v w x y z


Last edited by radoulov; 10-09-2007 at 03:39 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can I create 3 files in one command

Hi Gurus, I need to separate a file to 3 (based on column 1 value). I have code like below. it works. awk -F"|" '$1=="H" {print $0}' ${filename} > ${hea_name} awk -F"|" '$1=="D" {print $0}' ${filename} > ${det_name} awk -F"|" '$1=="T" {print $0}' ${filename} > ${tra_name} is it possible... (7 Replies)
Discussion started by: ken6503
7 Replies

2. Shell Programming and Scripting

How to create or convert to pdf files from csv files using shell script?

Hi, Can anyone help me how to convert a .csv file to a .pdf file using shell script Thanks (2 Replies)
Discussion started by: ssk250
2 Replies

3. Shell Programming and Scripting

Short command to create two files >{respo,nd}.php (with "tee" command?)

08:29 < xsi> >{respo,nd}.php bash: {respo,nd}.php: ambiguous redirect 08:31 < geirha> xsi: maybe you want tee So I was advised to do so. And I can't create two OR MORE files at once with {a,b,c,d,e,f}.php (which I quickly now need to create and to learn to create in the future to quickly... (2 Replies)
Discussion started by: Xcislav
2 Replies

4. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

5. Shell Programming and Scripting

Single command to create multiple empty files(no trailing lines as well).

Hi, i need a single command to create multiple empty files(no trailing lines as well) and empty the files if already existing. please let me know or if this has been ansered, if some ocan share the link please, thanks > newfile.txt or :> newfile.txt do not work (4 Replies)
Discussion started by: Onkar Banerjee
4 Replies

6. Solaris

Command to list all header files used to create an executable

All, I would like to know if there is a command which will list all the header files which were used while creating the executable. (1 Reply)
Discussion started by: helper
1 Replies

7. UNIX for Dummies Questions & Answers

how to create a command that would print files only from 1 folder

Hi there how to create a command in csh that would print files only from 1 folder but as an argument takes home directory for e.g. in my home diecrtory I have 3 folders unix, windows,mac and alot of files. and I running the program as ./op ~ this should return me files from unix folder without... (1 Reply)
Discussion started by: FUTURE_EINSTEIN
1 Replies

8. UNIX for Dummies Questions & Answers

Create individual tgz files from a set of files

Hello I have a ton of files in a directory of the format app.log.2008-04-04 I'd like to run a command that would archive each of these files as app.log.2008-04-04.tgz I tried a few combinations of find with xargs etc but no luck. Thanks Amit (4 Replies)
Discussion started by: amitg
4 Replies

9. UNIX for Dummies Questions & Answers

Creating create mirrored disk files systems using mkfs command

What is the correct mkfs syntax to create mirrored disk files systems? I need to make the file system 20gb. For example: machine# mkfs -F ufs /dev/md/dsk/d40 size not specified ufs usage: mkfs special size(sectors) \ -m : dump fs cmd line used to make this partition -V : print this... (4 Replies)
Discussion started by: GLJ@USC
4 Replies
Login or Register to Ask a Question