I NEED AN IMMEDIATE HELP

I NEED AN IMMEDIATE HELP

Post by Jubei Cha » Wed, 01 Jan 2003 01:39:47



hi everyone

i need a scrip that will have the output of

# ls -la | awk '{print $9}'

that is the filename. after getting the filename it will remove the file.

I have to wirte a script that will remove the files one by one
because there are so many files (about 600000)

help pls.

Thanks

 
 
 

I NEED AN IMMEDIATE HELP

Post by Thomas Glanzman » Wed, 01 Jan 2003 02:09:23


Quote:> i need a scrip that will have the output of

> # ls -la | awk '{print $9}'

> that is the filename. after getting the filename it will remove the file.

> I have to wirte a script that will remove the files one by one
> because there are so many files (about 600000)

Don't use caps lock! And bad practice anyway. In bourne shell syntax the
following should do

#!/bin/sh

ls -1 | while read FILE; do rm $FILE; done

or with your 'construct'

#!/bin/sh

ls -al | awk '{print $9}' | while read FILE; do rm $FILE; done

Greetings,
        Thomas
--
Rathsbergerstrasse 28     D-91054 Erlangen / Burgberg     +49 (0) 9131 - 614720

 
 
 

I NEED AN IMMEDIATE HELP

Post by Chris F.A. Johnso » Wed, 01 Jan 2003 02:12:15



> hi everyone

     The only way to get IMMEDIATE help is to search the archives, where
     you will find this topic discussed many times.

Quote:> i need a scrip that will have the output of

> # ls -la | awk '{print $9}'

    Why on earth would you do that instead of "ls -A"?

Quote:> that is the filename. after getting the filename it will remove the file.

> I have to wirte a script that will remove the files one by one
> because there are so many files (about 600000)

     You do not have to remove the files one by one; you can use
     xargs:

ls -A | xargs rm

--
    Chris F.A. Johnson                        http://cfaj.freeshell.org
    ===================================================================
    My code (if any) in this post is copyright 2002, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

 
 
 

I NEED AN IMMEDIATE HELP

Post by William Par » Wed, 01 Jan 2003 02:12:22



> hi everyone

> i need a scrip that will have the output of

> # ls -la | awk '{print $9}'

> that is the filename. after getting the filename it will remove the file.

> I have to wirte a script that will remove the files one by one
> because there are so many files (about 600000)

> help pls.

> Thanks

Since '-a' option will list all files/directories in current directory,
you end up deleting everything there.  In that case, a faster way is
    cd ..
    rm -rf ~-
or
    a=`pwd`
    cd ..
    rm -rf $a
    mkdir $a
    cd $a
or
    ls -a | xargs rm -rf
or
    find | xargs rm -rf
or
    rm -rf /    (fireproof way)

--

Linux solution for data management and processing.

 
 
 

I NEED AN IMMEDIATE HELP

Post by Matt » Wed, 01 Jan 2003 02:28:10




> > hi everyone

<snip>

Quote:>     rm -rf / (fireproof way)

I would very much advise against using this command.
 
 
 

1. Need immediate help with Awk! Thanks.

I'm typing the following command on a huge file:

awk '/^ISA/{x++}/^ISA/,/^IEA/{print>"o.edi"x}' JKFILE

This command looks in the file for ISA - IEA combinations and when it
finds it, it creates me a separate filename (o.edi)and also attaches to
the end of the file name a number.

Here's a piece of what the JKFILE would look like before I run awk on
it:

ISA*24567*444444*6666
BG*1*24567
IEA*2*24567
ISA*24668*55555*6666
BG*1*44556
IEA*3*56666

As you can see, there's two ISA-IEA groups in here and so after I run
the awk command on it, awk creates me two files called o.edi1 and
o.edi2.

Well, it's been working, but this time I have a very big file and when
I run the above awk command on it, I get some sort of error stating
that there's a maximum of 506 files that it can create.  I had no idea
that there was a limit to the amount of files that it could create for
me.  To be honest with you, there's probably 1500 individual ISA - IEA
combinations in the file.  Do you guys know of any ways to bypass this
problem?  It really screwed me today and I need help badly.  I'm all
for modifying the above awk command or using an entirely different
command to do the same thing.  THANKS.

Sent via Deja.com http://www.deja.com/
Before you buy.

2. poorly configured partion table

3. Advice - C Programming Books for Unix (Solaris 2.x)

4. immediate help needed

5. How to find semaphore ID from pid

6. URGENT!!: need IMMEDIATE help with telnet & escape-char usage

7. Printer problems

8. IMMEDIATE NEED CONSULTANTS

9. UNIX System Admin needed for immediate opening

10. Immediate Linux User Response Needed! Time Critical!

11. US-WI-UW-Madison Unix Systems Manager-Immediate need