help with Bash please....

help with Bash please....

Post by root » Mon, 25 Jun 2001 01:43:12



Can someone please explain to me why this isn't doing what I expect
(i.e. removing the named directories in the current directory), and
perhaps suggest a solution...


| cut -b 56-`; do rmdir $item;

Quote:> done  

rmdir: Boy Blue - Electric Light Orchestra
Can't Get It Out Of My Head - Electric Light Orchestra
Dark City (Demo) - Electric Light Orchestra
Eldorado
Eldorado - Electric Light Orchestra
Eldorado Finale - Electric Light Orchestra
Eldorado Instrumental Medley - Electric Light Orchestra
Eldorado Overture - Electric Light Orchestra
Eldorado Remastered.nfo
Illusions in G Major - Electric Light Orchestra
Laredo Tornado - Electric Light Orchestra
Mister Kingdom - Electric Light Orchestra
Nobody's Child - Electric Light Orchestra
Poor Boy (The Greenwood) - Electric Light Orchestra: File name too long

How do I get the files in a directory to list singly?

Thanks...

 
 
 

help with Bash please....

Post by Joe Halpi » Mon, 25 Jun 2001 02:09:09



> Can someone please explain to me why this isn't doing what I expect
> (i.e. removing the named directories in the current directory), and
> perhaps suggest a solution...


> | cut -b 56-`; do rmdir $item;
> > done  
> rmdir: Boy Blue - Electric Light Orchestra
> Can't Get It Out Of My Head - Electric Light Orchestra
> Dark City (Demo) - Electric Light Orchestra
> Eldorado
> Eldorado - Electric Light Orchestra
> Eldorado Finale - Electric Light Orchestra
> Eldorado Instrumental Medley - Electric Light Orchestra
> Eldorado Overture - Electric Light Orchestra
> Eldorado Remastered.nfo
> Illusions in G Major - Electric Light Orchestra
> Laredo Tornado - Electric Light Orchestra
> Mister Kingdom - Electric Light Orchestra
> Nobody's Child - Electric Light Orchestra
> Poor Boy (The Greenwood) - Electric Light Orchestra: File name too long

> How do I get the files in a directory to list singly?

I think resetting IFS is giving you a problem. If all you want to do
is remove the directories, try something like this.

for f in *;do [ -d "$f" ] && rmdir "$f";done

If you put double quotes around $f, you don't have to reset IFS.

Joe

 
 
 

help with Bash please....

Post by Cyrille Lefevr » Mon, 25 Jun 2001 06:49:01



> Can someone please explain to me why this isn't doing what I expect
> (i.e. removing the named directories in the current directory), and
> perhaps suggest a solution...


> | cut -b 56-`; do rmdir $item;
> > done
[snip]
> How do I get the files in a directory to list singly?

how about rmdir */

Cyrille.
--


Supprimer "%no-spam" et ".invalid" pour me repondre. | about who it chooses
Remove "%no-spam" and ".invalid" to answer me back.  | to be friends with.

 
 
 

help with Bash please....

Post by Bill Marcu » Mon, 25 Jun 2001 11:07:40



>Can someone please explain to me why this isn't doing what I expect
>(i.e. removing the named directories in the current directory), and
>perhaps suggest a solution...


'^d'
>| cut -b 56-`; do rmdir $item;
>> done
>rmdir: Boy Blue - Electric Light Orchestra
>Can't Get It Out Of My Head - Electric Light Orchestra
>Dark City (Demo) - Electric Light Orchestra
>Eldorado
>Eldorado - Electric Light Orchestra
>Eldorado Finale - Electric Light Orchestra
>Eldorado Instrumental Medley - Electric Light Orchestra
>Eldorado Overture - Electric Light Orchestra
>Eldorado Remastered.nfo
>Illusions in G Major - Electric Light Orchestra
>Laredo Tornado - Electric Light Orchestra
>Mister Kingdom - Electric Light Orchestra
>Nobody's Child - Electric Light Orchestra
>Poor Boy (The Greenwood) - Electric Light Orchestra: File name too long

>How do I get the files in a directory to list singly?

It seems obvious, you need a newline in IFS.  The default value
for IFS is <space><tab><newline>.
  IFS=\
;for item in `ls -Al | grep -E '^d' | cut -b 56-`; do rmdir $item;
done
'$' means end of line in regular expressions, but 'IFS=$' sets the field
separator to a literal dollar sign.
 
 
 

1. BASH BASH BASH BASH BASH BASH BASH BASH BASH BASH

Is there a proper fixed bash on any of the FTP sites out there?

I know there bash is on the usual sites but I don't know if they are
bugged or not :(

Regards,

Neil.

--


------------------------------------| Edinburgh, EH14 2DE, United Kingdom
**Domino: There`s nothing you can do when you`re the next in line: Domino**

2. Processes in UNIX

3. PLEASE PLEASE HELP Major problem with my SCSI & Redhat 5.0 PLEASE Help

4. Personal web pager?

5. Sendmail problems. Please please please please help!

6. perl

7. NFS please help me please please please sniff

8. difference between using ioctl and socket/getsockopt

9. Bash Scripting problem... Please help

10. Please help, Windowmaker works only if csh is used, but not bash

11. Help with Bash scripting please :)

12. Bash Question - Please help

13. bash function problem, unless su is used - please help!