The Linux Administration group is for the discussion of technical issues technical issues that arise during the administration of Linux systems, including maintaining the operating system and supporting end-user applications.

RM command

hi every one ... i got a problem .... i have a folder where the users should
save files...
my idea i just wanna write script and put that in cron job..
can any one tell me how to remove the all the files except with file
extensions jpg ,jpeg, bmp.,png...
by using rm command

OK. But what would happen to the other files in the same directory with
extension of:

jpeg, bmp.,png ?

It looks like rm -rf * !=*.jpg will only skip files with extension of *jpg* an
delete everything else.

Can a conditional operator be used such as (or, and) with the rm command?
If this is not possible, a simple script can be written using either awk or
grep or anything in the arsenal to handle this simple issue.

after that execute:
$ dir
and take a look of what do you have in the directory.
write on the terminal:
$ rm --help
and consider what to do next.
After cleaning the directory return the image files (for further details how to do this see $ mv --help).
Regards

Hi,
In my view the essence of the problem is not in executing the task in one command line on the terminal (for it maybe series of commands organised in .sh file for example), but rather to have maximum security in executing high-risk operations of the kind:
$ rm -fR *
with inability to restore the data after that.

Suppose you have in the directory some .gif image or .m4v image or slide show - all that will go straight in 'the Dimension X' with the execution of the 'file extensions' command.
Regards

You can also move them to a directory named "questionable_files"( or
something like hat of your own choosing) instead of removing them, and when
short of disk space, do a quick ls in hat directory before actually removing
most or all of the files.

Hi,
In my view Backup would hardly be of any help if you go to a wrong directory and remove the files from there.
With this 'rm' command in automatic mode (with some 'force remove' option, for example) you have no problems to outwhistle the whole OS beyond recovery and you don't need even to be in /root for the purpose.

Hi,
In my view Backup would hardly be of any help if you go to a wrong directory and remove the files from there.
With this 'rm' command in automatic mode (with some 'force remove' option, for example) you have no problems to outwhistle the whole OS beyond recovery and you don't need even to be in /root for the purpose.

Hi,
This Android tablet is intended to work with Android (OS) of Google (based on linux kernel), and WinCE is analogical development of such OS by MS (based on Windows). As you know Linux and Windows are mixing up exactly like petrol and water (even the Wine emulator is of little or no use).

If I were to use the Android tablet I would install straight out Android OS.

Hi,
Thanks for the answer but I just want to write a script for my problem where I need
to deleted all the files except image files...
The thing is Ii have a folder shared in samba since the users are using
windows xp and users should save their files in that folder...say folder
named /data which is been shared in samba
But the users are allowed only to save image files not any other files....
so I need a script which I will put it in cronjob so that the files other
than image files are deleted as the cron job runs for particular time which
i give ....

* * * * * /bin/sh script ------- this is the entry
which i wanna give in crontab

but what is that I need to write in the script to execute....
waiting for solution ( image files are all including jpeg,jpg,bmp
.png....etc...)

Isn't the below command exactly what he doesn't want to do?
I believe he wants to save these files with extension jpq, peg, bmp and png.
Also doing a find and pipe to grep might not work. The # of files and excess the buffer to PIPE.
You should use "-not -name" option with find

Which command are you referring? This one is flawed in a couple of ways:

find / -type f |grep "jpg|jpeg|bmp|png" | exec rm -f {} \;

1. you need to use egrep if you're going to search for multiple strings.
2. even if it did work, it would find any file that contained any of
those strings. The OP wants files that have those extensions, so you
will need to anchor the grep strings.

> I believe he wants to save these files with extension jpq, peg, bmp and png.
> Also doing a find and pipe to grep might not work. The # of files and excess the buffer to PIPE.
> You should use "-not -name" option with find
>

Thanks for pointing that out wanderedinn. To be fair, I didn't hijack the thread. I was responding to a notification email from ittoolbox.com with the title of "Android & WinCE". If you will follow this link http://it.toolbox.com/people/christo-petkov/ and check Christo's most recent post, you will find that it will wrongly direct you back to this page. This is probably because last post link on http://it.toolbox.com/people/master_rod/ also incorrectly directs the "Android & WinCE" discussion to this page.
However, I do appreciate the irony as I am fairly aggressive about keeping posts on topic. I imagine Lee might have something to say about all of this.

Hi,
The portability is nothing in comparison to the inability to react promptly. Suppose you trade Forex on such a gadget (MID) - always there will be somebody somewhere with faster computer and with better accessibility, who will hijack from you ... the liquidity of the trade, for example.
As about this 'hijacked' thread - maybe I have partial fault (0.5%, for I changed the reference line on the resent e-mail of the Android tablet story), but it was Android & WinCE, and how the RM command line came here ... I really have no idea.
Regards

What are you talking about ergonomics? MIDs are square and thin, What they
need is a fast processor, more ram, longer battery life, USB, and the
ability to change out OS. I really like my 7" MID from China. The only
problem is the Android OS is still very young and apps are for kids mostly.
I had a tablet with Windows CE, but was rather limited. I also could not
download a more complete version as with Microsoft, every thing is money.
Apple's IPad is beautiful except, it has little memory, no SD Memory port,
and no USB. It is pretty much well crippled. Oh well, new gadgets are coming
down the line....Enjoy.

It is not about the thickness (of the screen). We are talking about convenience at work. When I work, for example on a laptop with a fabulous mouse or on a tablet or something of the kind I feel as if both of my hands are broken in the wrists - elementary operations turn into the 'Labyrinth of the Minotaver'.

RE: The processor
What about Intel Quad series with GB LAN on the mother board, and a direct satellite Internet connection, and also a GPU for graphic processing, class teraflops.
.. and the USB ports should be at least four - 1 for external keyboard, 1 for external mouse, 1 for USB flash card, and 1 for additional monitor.

In a conclusion: The tablets are and will remain cross-technological misunderstanding unless the problem of the ergonomics is resolved.
Mobility is unlikely to be of any benefit here. If you tie up the tablet to a kite it will become even more mobile and even more inaccessible.

Hi,
You may put a check in the program code for access of the user to the server, if the files are not .jpg .jpeg. .png .bmp etc., not to be able to be written on the hard disk of the server at all.
This approach is much more safe than using 'rm' command subsequently, or as a Cerberus or whatever.