The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Create individual tgz files from a set of files amitg UNIX for Dummies Questions & Answers 4 04-29-2008 09:13 AM
compare files and create new with awk tonet Shell Programming and Scripting 7 12-27-2007 10:05 AM
on how to create files fiol73 UNIX for Dummies Questions & Answers 2 12-19-2006 07:41 AM
Creating create mirrored disk files systems using mkfs command GLJ@USC UNIX for Dummies Questions & Answers 4 11-07-2006 01:52 PM
How to compare several files and create a new one alxkn UNIX for Dummies Questions & Answers 1 07-17-2006 11:04 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-09-2007
jess_t03 jess_t03 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 59
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 Bash create file with name 88[11-78]
But it very long command I wanna create it easy
This is possible ?
  #2 (permalink)  
Old 10-09-2007
timontt timontt is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 44
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 (permalink)  
Old 10-09-2007
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,953
Quote:
Originally Posted by timontt View Post
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....
  #4 (permalink)  
Old 10-09-2007
timontt timontt is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 44
Good catch... DukeNuke2. Thanks!
  #5 (permalink)  
Old 10-09-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Quote:
Originally Posted by jess_t03 View Post
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 Bash create file with name 88[11-78]
But it very long command I wanna create it easy
This is possible ?
bash, zsh, ksh93:

Code:
touch {8811..8878}
  #6 (permalink)  
Old 10-09-2007
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 2,953
Quote:
Originally Posted by radoulov View Post
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
  #7 (permalink)  
Old 10-09-2007
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Quote:
Originally Posted by DukeNuke2 View Post
nice one! but it only works in zsh for me... not in bash or ksh. but anyway, a really nice one
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 02:39 PM..
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0