[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

POSIX scripting tip



[ Paul Slootman writes ]
> On Tue 03 Oct 2000, Philip Brown wrote:
> > Get in the habit of using POSIX compliant syntax for shellscripts.
> > It will help everyone in the long run.
> > ...
>
> This only works for single character things, and when what you're
> trying to expand is in the filesystem.
> Try this in sh:
> 
> 	cp verylongfilename{,.orig}

I'm taking about scripting specifically. What you give as an example is
something you'd do on the command line.
Something that people not familiar with command line editing would to, too.
It's almost the same about of keystrokes as

cp verylongfilename
  [ESC-b C-k C-y space C-y ".orig"]


three chars vs 5 chars.

[and this works in both bash and POSIXsh. ainit kool? :-)]


   ------------------------------

Anyways, since you bring up that sort of thing, I thought I'd mention
something folks dont often know about: POSIX SH supports something vaguely
similar to   {,} notation in CSH.
 [Not the odd "file isnt there yet" syntax of bash you give above.
  I consider that a BUG, not a feature]

If you have files
fiftyfive fiftyfour fiftyone fiftysix fiftythree fiftytwo

$ ls fifty?(one|f*)

will result in

fiftyfive   fiftyfour   fiftyone



Reply to: