Help required on scripting the rm -f command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help required on scripting the rm -f command
# 1  
Old 08-24-2008
PHP Help required on scripting the rm -f command

When i execute rm -f $1 via a script file named rmf, it is not deleting all the files, say starting with "sec". i have execute rmf for many times to remove all the occurrences...

$rmf sec* - this should delete all files starting with sec, but not.

The rm -f sec* is working fine. kindly help me to crate a script file for this command.

</div>
# 2  
Old 08-24-2008
Is this part of a bigger script, or are you just trying to save yourself some keystrokes? Wouldn't it be easier to just alias rm -f to rmf?
# 3  
Old 08-24-2008
When you type the command, the shell replaces 'sec*' by the list of files slected by this pattern :
Code:
> ls sec*
sec1.dat  sec2.dat  sec3.dat
> set -x
> rmf sec*
+ rmf sec1.dat sec2.dat sec3.dat
>

In your script, you delete only the first file ($1).
If you want to delete all the files you must specify "$@":
Code:
rm -f "$@"

Jean-Pierre.
# 4  
Old 08-25-2008
* is replaced by all the files in the directory you are standing.
so your scripts gets $1 as the first file, and $2 as the second and and and
maybe you could use getops for that
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting help required

I have a shell script which calls a sql script. But in the output file I'm getting an additional '^L' character. Please advise how this is to be handled. spool /opt/oracle/DART/out/Indx_rebuild.out SET SERVEROUTPUT ON SET VERIFY OFF SET HEADING OFF SET NEWPAGE NONE SELECT 'ALTER INDEX '||... (2 Replies)
Discussion started by: narayanv
2 Replies

2. Shell Programming and Scripting

Required help in shell scripting

Iam new to shell scripting,i have a text file in my $home directory mentioned below. 201249_BAN_EXCL.TXT I need to refer the above file in my automated script but the number 201249 used to change every week.How can i refer to this file everyt time without renaming it manually? Thanks in... (7 Replies)
Discussion started by: Jroyal
7 Replies

3. Shell Programming and Scripting

guidance required: feed load search & display in shell scripting

Hi All, I am fairly new to Shell Scripting, however learning fast ;-) I have been asked to do the below basic shell script :confused: There are few feed files we are recieving in the server from multiple locations spread out during the day, rite now we are checking manually each file... (2 Replies)
Discussion started by: sachaan
2 Replies

4. Shell Programming and Scripting

Little scripting help required.

Hi , I need little help regarding my script. I have a file called abc which looks below. Rohan 12 Rakesh 23 Ajay 25 Another file looks like this (xyz). Mumbai Delhi Madras How would i add column mentioned in second file so that the file looks as below. Rohan 12 Mumbai... (2 Replies)
Discussion started by: pinga123
2 Replies

5. Solaris

Required UNIX shell scripting material

As I am new in UNIX , and I want to learn UNIX shell scripting. where shall I get material for Scripting ( For basics fundamentals and production environmental scripts) Kindly provide me ...................... (7 Replies)
Discussion started by: sunray
7 Replies

6. Shell Programming and Scripting

Help Required in shell scripting

Hi, I am new to Unix shell scripting.I have a requirement where I have to search for a particular file in a Unix directory based on some criterian of the content of the file.Actually there would be two files with same name and then I have zip them together and stoe in the same directory. As... (1 Reply)
Discussion started by: Kunal Banerjee
1 Replies

7. Shell Programming and Scripting

Help required with formatting in scripting

Hi Friends, I need to write a script which reads the file and prints them horizontally. For example, the file contains something like x1 x2 x3 x4 x5 my script reads this file as "for i in `cat filename`", but I need an output something like "config file = x1.ccfg,... (3 Replies)
Discussion started by: dineeshkg
3 Replies

8. UNIX for Dummies Questions & Answers

DNS forward and reverse entry required thorugh scripting instead of manually done

HI GUrus, I am very mcuh new for this forum ....i need you all guys help for resolving my queries. As i have DNS server , platform is sunsolaris----8. We are using that serevr for resolving all network nodes. I am going to explain the process what i am following .... I could have... (2 Replies)
Discussion started by: leenagoyal
2 Replies

9. Shell Programming and Scripting

SFTP scripting - help required

Hi all, First post so go easy guys....... I've seen this asked before on some other forums but never properly/fully answered. My problem involves the automation of an SFTP script sending from F-Secure (ssh2) HP-UX, to Windows FTP server (ssh2) running VShell. We've set up SSH keys but while... (8 Replies)
Discussion started by: b0bbins
8 Replies

10. UNIX for Dummies Questions & Answers

Help required on expect scripting

I am trying to write an expect script for remote server login. At some point of time I need to telnet based on the output of grep command. Based on the output I need to select the ip address of the server. How can I write an expect script for the same. The output of the grep command is as follows:... (1 Reply)
Discussion started by: ayyappakumar
1 Replies
Login or Register to Ask a Question