removal of files?

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions removal of files?
# 1  
Old 10-18-2010
removal of files?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
remove all files and only files that the first three characters start with numerals.


2. Relevant commands, code, scripts, algorithms:
none


3. The attempts at a solution (include all code and scripts):
rm -ri [09-]*[!0-9]
rm -ri [0-9]file
rm -ri {0-9,0-9,0-9,a-z,A-Z}
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
wastenaw community college, Ann arbro Michigan, Geyer, CIS121/Linux/Unix fundamentals

Side Note: I made files called [123file,675file 777file, and 1file] each time I do any of the codes listed above it will bring [1file] to the equation amd I just would like to know if you can't do this problem without that happening.
Thank you.
Note: I really like to try to figure out problems myself but I keep getting the same resaults I think the way I did this is the only way to do it just want to make sure(
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 10-18-2010
I know in course section i am supposed to add comment but i think the following command is self-explicit enough
If you have adding question, please feel free to shoot

Code:
rm -ri [0-9][0-9][0-9]*

# 3  
Old 10-18-2010
It worked thank you very much. I have no idea why I did'nt think of that. Thank you again.
# 4  
Old 10-18-2010
Why does the problem statement contradict itself with "all and only"?

Why the -r to remove matching directories and their sub-trees?
Why the -i to ask for each?

rm [0-9][0-9][0-9]*
# 5  
Old 10-18-2010
LoL DGP

You're true, i focused of the pattern ... i didn't even care of these options and just copied them like a stupid robot LoL ....
# 6  
Old 10-18-2010
And what characters start with numerals Smilie

---------- Post updated at 21:49 ---------- Previous update was at 21:38 ----------

The description is quite ambiguous. You don't suppose what is meant is to remove only files that are regular files and not symbolic links or named pipes or what have you? In that case I think a find statement would be in order.
# 7  
Old 10-18-2010
Or ls -l, sed, xargs:
Code:
ls -l | sed '
  s/^-.* \([0-9]\{3\}[^ ]*\)$/\1/
  t
  d
 ' | xargs -n 101 rm

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removal of space

Hi , Can any one help me out how to remove space from below line select file_name from dba_data_files where tablespace_name='SYSTEM ----space---- '; i want as : select file_name from dba_data_files where tablespace_name='SYSTEM'; my code i use file=/u01/script/latest/tbs.temp while... (14 Replies)
Discussion started by: Praful Pednekar
14 Replies

2. Shell Programming and Scripting

Removal of extra spaces in *.log files to allow extraction of frequencies

Our university has upgraded its version of a computational chemistry program that our group uses quite regularly. In the past we have been able to extract frequency spectra from log files that are generated. Since the upgrade, the viewing program errors out. I've been able to trace down the changes... (16 Replies)
Discussion started by: wsuchem
16 Replies

3. Shell Programming and Scripting

bash script using scp (pw typed by hand) followed by removal of files

Hello, I tried to write a bash script (code is below) that does scp files that contain a certain string, and that subsequently deletes only those files that have been copied (in my case new files are created every second so it is important to only delete those that have been copied). The key is... (0 Replies)
Discussion started by: kjartan
0 Replies

4. UNIX for Dummies Questions & Answers

removal by substring

Hi guys, I am trying to remove lines that have a duplicate substring from any part in the file. So, for ex: 433043950359.3 5033 305935 2 2dd 5ffgs DOG43453552.A 3443565634 95460 3435 45 23d 56ggh DOG343211 3423895702359 34 66699 9455 2324 DOG43453552.B This is a very large file, and... (1 Reply)
Discussion started by: verse123
1 Replies

5. Shell Programming and Scripting

Removal of files/folders created during a period of time

Hi, I have some folders (containing files) which gets created daily and names start with 'TT_' . I would like to remove these folders every month end. Could you please provide me the commands and also the syntax to schedule through crontab. Thanks, Archana (3 Replies)
Discussion started by: archana.n
3 Replies

6. Shell Programming and Scripting

\n removal between two |

I have a multi-line string I'm trying to do some clean-up on. Example: 1|575|67866|"fgnhdgj"|"afhgajh agfajgf ahfjhgfk ahfkhf"|568 2|56|5435|"mayank"|"gupta gdja agdjagf"|677 3|5666|5435|"mayank"|"gupta gdja agdjagf"|677 I need a shell script that replace all \n under " ". (11 Replies)
Discussion started by: mayankgupta18
11 Replies

7. UNIX for Dummies Questions & Answers

semaphore removal

I have one process which creates semaphore with permission 600. Then at some part of the code I have line where this semaphore will be removed. Problem I have is that other processes in my program also try to execute this line of code. Of course since they dont have permission they wont be able to... (1 Reply)
Discussion started by: joker40
1 Replies

8. Red Hat

RPM Updation & Keeping User Change files during removal

Hi All, I have a RPM for an Java based application. Currently it works fine. But recently I want to implement that when newer packages gets installed over the older one, the rpm should only update the older files with the newer one (I know this could be done by rpm -Uvh xxx.rpm), but it... (0 Replies)
Discussion started by: jw_amp
0 Replies

9. Shell Programming and Scripting

sftp validate files before removal

I have a shell, which locks calls an expect script that connects to an sftp and downloads all files. I need it to then check each file in my directory and compare the sizes. If the file name and file size match, then delete the file on the server. Is this possible? :confused: (2 Replies)
Discussion started by: tariqjamal
2 Replies

10. UNIX for Dummies Questions & Answers

Removal

I am using Unix as my OS on my server and would like to format my hard drive. How do I go about wiping my hard drive or is there a removal tool that I can use? (1 Reply)
Discussion started by: anaconda
1 Replies
Login or Register to Ask a Question