Sponsored Content
Top Forums Shell Programming and Scripting Create files with one command Post 302139856 by radoulov on Tuesday 9th of October 2007 02:30:05 PM
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..
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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. 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

7. 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

8. 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

9. 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
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/ksh93 /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/ksh93 /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/sfw/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. NOTES
Restricted shells should not be listed in /etc/shells. SunOS 5.11 1 Nov 2007 getusershell(3C)
All times are GMT -4. The time now is 11:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy