Re: [opensuse] bash { list } question



On Wednesday 14 May 2008 18:48:17 David C. Rankin wrote:
Listmates,

I am trying to use a bash list to move a group of files and directories
under a single directory. It works, but I get a bash error I want to
eliminate. How do I do it right so I can eliminate the error? Here is the
situation. I want to move the following files and directories except
"server" under the "desktop" directory with a single command:

drwxr-xr-x 2 david skyline 4096 2007-12-16 10:43 calc/
drwxr-xr-x 2 david skyline 4096 2007-07-24 21:34 crypto/
drwxr-xr-x 2 david skyline 4096 2008-05-14 11:37 desktop/
-rwxrwx--- 1 david skyline 4619908 2007-12-08 05:37 jpgraph-2.3.tar.gz*
-rw-r--r-- 1 david skyline 608608 2008-02-21 22:43 kdesudo-2.4.tar.gz
-rw-r--r-- 1 david skyline 503468 2008-03-03 20:38 KeePassX-0.3.0.tar.gz
-rw-r--r-- 1 david skyline 27754 2008-03-03 02:42 pblogan-0.0.6-1.tar.gz
drwxr-xr-x 2 david skyline 4096 2008-05-14 11:37 server/
-rw-r--r-- 1 david skyline 3251965 2008-02-22 21:17 sim-0.9.4.3.tar.bz2
-rwxr--r-- 1 david skyline 1050048 2008-02-22 22:04 trix-0.93.tar.bz2*
-rw-r--r-- 1 david skyline 266574 2008-04-01 21:45 xca-0.6.4.tar.gz

I used this command line:

[11:38 nirvana/home/samba/computer/linux/apps] # mv { c* k* K* p*
sim-0.9.4.3.tar.bz2 trix-0.93.tar.bz2 xca-0.6.4.tar.gz } desktop/

It all worked, but I got this error:

mv: cannot stat `{': No such file or directory
mv: cannot stat `}': No such file or directory

Which makes sense because I didn't want the braces as directories only as
list enclosures. How do I do it so I can eliminate the brace error?

What exactly is a "bash list"?

mv can handle multiple files, as long as the last parameter is a directory to
be used as destination, so you don't need anything fancy from bash here. Just
do

mv c* k* K* p* sim-0.9.4.3.tar.bz2 trix-0.93.tar.bz2 xca-0.6.4.tar.gz desktop/

and it will work.

I'm not sure at all where you found the idea of a bash "list" though. The
bracket notation in bash normally means that you want to execute commands in
the current shell (as opposed to the () notation, which means bash should
launch a subshell for the commands).

Maybe you were confused by the notation

{ list; }

in the bash man page, but that just means it should be a list of commands to
be executed (the basic idea is that you're interested in the whole as a group,
so if one command fails, it should go on to the next command after the closing
bracket)

Anders

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx