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



Relevant Pages

  • Re: MC Alternative? (File Managers)
    ... >> almost every personal computer in existence and are considered ... >> stripped down file manager for the console. ... > combination of programmable F# keys (through bash) and bash ... > by your shell (there are no built-in commands). ...
    (comp.os.linux.misc)
  • Re: MC Alternative? (File Managers)
    ... >> almost every personal computer in existence and are considered ... >> stripped down file manager for the console. ... > combination of programmable F# keys (through bash) and bash ... > by your shell (there are no built-in commands). ...
    (comp.unix.questions)
  • Re: why wont my awk if/else work for both conditions?
    ... output1.txt; then echo y; else echo n; fi ... bash - but then stops. ... commands executed while in sh. ... but only when i type it directly into the prompt - not ...
    (comp.unix.shell)
  • Re: PYTHONPATH
    ... The error indicates the shell tried to execute a program named '1' and couldn't find one. ... Arthimetic expressions generally have to be wrapped in ) in bash: ... non-interactive shell with the --login option, it first reads and executes ... commands from the file /etc/profile, ...
    (comp.lang.python)
  • Re: Make OS X terminal work like linux
    ... MacOSX 'Terminal' application IS bash, so all of the basic built-in bash ... commands are exactly the same as under Linux. ... Linux -- it should be possible to find a BSD vs. Linux comparison with a web ... 'system administration' on a Mac are probably best handled with the supplied ...
    (comp.os.linux.misc)