Code Comments
Programming Forum and web based access to our favorite programming groups.I'm struggling with batch files moving.
I have several files named "file 001.jpg" #contains two blank spaces
or "file 002.jpg" #contains one blank space
I would like to know how to move them using system() in awk.
I can print them:
ls | awk '{print $1"_"$2}'
but how to move them from source to target file?
Svata
Post Follow-up to this messageptjm@interlog.com (Patrick TJ McPhee) wrote in message news:<2s8mq4F1hrf51U1@uni-berlin.de> .. > > And of course in this newsgroup, you made the right choice. You could > do it all using a Bourne-compatible shell, like this > > for a in * > do > set -- $a > mv "$a" $1_$2 > done Well, there are several approaches to same task. Awk is handy as its syntax is really space saving. Sorry, if I date too much, but can you tell me what "set -- $a" exactly does? Svata
Post Follow-up to this messageSvatoboj wrote: > ptjm@interlog.com (Patrick TJ McPhee) wrote in message news:<2s8mq4F1hrf51 U1@uni-berlin.de>... > > > > Well, there are several approaches to same task. Awk is handy as its > syntax is really space saving. > Sorry, if I date too much, but can you tell me what "set -- $a" > exactly does? sets the postional parameters $1, etc. to be whatever space-separated values are stored in $a. For more details, look up the "set" command in your shells man page (e.g. http://www.rt.com/man/ksh.1.html for ksh). Ed. > Svata
Post Follow-up to this messageEd Morton <morton@lsupcaemnt.com> wrote in message news:<4OednV5VH8aa2_zcRVn-hA@comcast.com >... > > sets the postional parameters $1, etc. to be whatever space-separated > values are stored in $a. For more details, look up the "set" command in > your shells man page (e.g. http://www.rt.com/man/ksh.1.html for ksh). Thank you for your reply. I looked up "set" command in BASH manual page, but I still don't understand how it works. > > Ed. > Svata
Post Follow-up to this messageOn 2004-10-05, Svatoboj wrote: > Ed Morton <morton@lsupcaemnt.com> wrote in message news:<4OednV5VH8aa2_zcR Vn-hA@comcast.com>... > > > Thank you for your reply. I looked up "set" command in BASH manual > page, but I still don't understand how it works. What don't you understand? There are three functions to set (taken from the bash man page): 1. Without options, the name and value of each shell variable are displayed in a format that can be reused as input. 2. When options are specified, they set or unset shell attributes. E.g., set -f, set -x, set +v 3. Any arguments remaining after the options are processed are treated as values for the positional parameters and are assigned, in order, to $1, $2, ... $n. -- Chris F.A. Johnson http://cfaj.freeshell.org/shell ======================================== =========================== My code (if any) in this post is copyright 2004, Chris F.A. Johnson and may be copied under the terms of the GNU General Public License
Post Follow-up to this messageIn article <61792dff.0410050132.7b5a68b8@posting.google.com>, Svatoboj <svatoboj@centrum.cz> wrote: % Thank you for your reply. I looked up "set" command in BASH manual % page, but I still don't understand how it works. Set allows you to restate the shell's command line. You can set shell options and replace positional parameters. If you write set $whatever the shell expands the shell variable `whatever', then divides it up using the value of IFS or white space if IFS is not set, and assigns each piece to a positional parameter. For instance whatever="a b c" set $whatever echo $2 will print `b'. This doesn't work correctly if $whatever has no value or it begins with - or +. I used -- to say that the rest of the command line should be assigned to positional parameters. whatever="-a b c" set $whatever echo $2 # prints c set -- $whatever echo $2 # prints b -- Patrick TJ McPhee East York Canada ptjm@interlog.com
Post Follow-up to this messageptjm@interlog.com (Patrick TJ McPhee) wrote in message news:<2s8mq4F1hrf51U1@uni-berlin.de> .. > > And of course in this newsgroup, you made the right choice. You could > do it all using a Bourne-compatible shell, like this > > for a in * > do > set -- $a > mv "$a" $1_$2 > done Well, there are several approaches to same task. Awk is handy as its syntax is really space saving. Sorry, if I date too much, but can you tell me what "set -- $a" exactly does? Svata
Post Follow-up to this messageSvatoboj wrote: > ptjm@interlog.com (Patrick TJ McPhee) wrote in message news:<2s8mq4F1hrf51 U1@uni-berlin.de>... > > > > Well, there are several approaches to same task. Awk is handy as its > syntax is really space saving. > Sorry, if I date too much, but can you tell me what "set -- $a" > exactly does? sets the postional parameters $1, etc. to be whatever space-separated values are stored in $a. For more details, look up the "set" command in your shells man page (e.g. http://www.rt.com/man/ksh.1.html for ksh). Ed. > Svata
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.