Sponsored Content
Top Forums Shell Programming and Scripting Help need with remove command Post 302781507 by pinnacle on Saturday 16th of March 2013 07:48:34 PM
Old 03-16-2013
Thanks I was not aware that
Code:
printf pattern*

and
Code:
echo pattern*

will list files.

I thought
Code:
ls pattern*

was only command to list files. Thanks for the information.

When I just do

Code:
 
printf pattern*

It lists only one file and then the command prompt also comes on same line.

Whereas when I do

Code:
 
echo pattern*

It list all files and command prompt comes on next line.

Could you please let me know the following:
1. When should we use
Code:
printf or echo

command instead of ls command.
2. Why the printf command I showed above list only one file. Where as
Code:
 
printf "\t%s\n" pattern*

list all files.
3. I am not expecting any blank space in the file name that needs to be removed but incase blank space is part of the file name. Will it just not delete that file or will it mess up the server files in root directory or any other directories.

I appreciate all your help and explaination.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

search and remove command

I want to run the 'locate' command and then remove what the command finds. My guess was, locate blahblah |rm -f but this does not work. Thanks! (3 Replies)
Discussion started by: jasonr
3 Replies

2. UNIX for Dummies Questions & Answers

command to remove last record on file

Hi, First time on the forum. I have converted some files using the Unix to DOS command but need to strip off the last record that is generated from this conversion that contains just a ^Z. Is there any command that would accomplish this without having to do stream editing? (4 Replies)
Discussion started by: mheinen
4 Replies

3. Shell Programming and Scripting

rm command not able to remove file

I have directory IXNPG7 under which i have seen file ads.c , ads.gif , ads.js and lots more with extension .html I tried to remove the Entire Directory with rm -Rf IXNPG7 but it is saying -- Directory Not empty can't remove Secondly i tried removing all the files first using rm *.*... (7 Replies)
Discussion started by: jambesh
7 Replies

4. UNIX for Dummies Questions & Answers

Find and remove command - can you tell me exactly what its doing?

find /app01/tomcat_local -name *jsp* -type f -exec rm -r {} \; I would assume the above is just deleting any *jsp* below the /app01/tomcat_local directory - is this correct as its seems to delete more than I expect.... (1 Reply)
Discussion started by: frustrated1
1 Replies

5. UNIX for Dummies Questions & Answers

inverse remove command

Hi All, Is there an option for 'rm' to "remove everything but these files"? For instance if I have: a.txt <-- I just want to remove this one a_1.txt a_2.txt Is there an option ? for this: rm -? *_*.txt Thanks, ScKaSx (4 Replies)
Discussion started by: ScKaSx
4 Replies

6. UNIX for Dummies Questions & Answers

Command to remove First and Last line from a File

I have a file from which the Header and the Trailer lines need to be removed. They are confirmed to be the first and the last lines in the file. I have tried a few commands, but not successful yet. It needs to be implemented urgently, hence any help is greatly appreciated. Raghu ----------... (1 Reply)
Discussion started by: ragz_82
1 Replies

7. AIX

Unable to remove files from rm command

I need to delete some files which are not getting removed not even from root user -rw-r----- 1 ptml tellin 0 Jul 26 19:23 temp.out1 -rw-r----- 1 ptml tellin 0 Jul 26 19:23 temp.out -rw-r----- 1 ptml tellin 2 Jul 26 19:23 prev -rw-r----- 1... (4 Replies)
Discussion started by: m_usmanayub
4 Replies

8. Shell Programming and Scripting

simple remove command -ksh

KSH A simple remove command is not workin for me. The user has all the access and the return code after remove command is 0. But I am still able to find the file. I have the code as below. tmplog=/tmp/$fl_nm.$$ main () { --set of statments rm -fr $tmplog RC=$? } (2 Replies)
Discussion started by: tostay2003
2 Replies

9. UNIX for Dummies Questions & Answers

cut or remove command

hi, I want to remove first word in all files where first and second word is seperated by comma. example: a file contains Apple,mango. i need only mango shoule be there in the file??? Apple, should be removed!!!!! can anyone help me out??? thanks in advance, Arun Manas:b: (2 Replies)
Discussion started by: arunmanas
2 Replies

10. Shell Programming and Scripting

Can not remove file using rm command

I have two questions: the first is I have a line of code: printf "What is the id of the patient getting GJB2 analysis : "; read id that stores a user input in a variable $id in the python directory c:/Users/cmccabe/Desktop/Python27/$id.txt Using rm I get the error cannot remove ... (21 Replies)
Discussion started by: cmccabe
21 Replies
SHELL-QUOTE(1)						User Contributed Perl Documentation					    SHELL-QUOTE(1)

NAME
shell-quote - quote arguments for safe use, unmodified in a shell command SYNOPSIS
shell-quote [switch]... arg... DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands or files with embedded white space or shell globbing characters safely. Here are a few examples. EXAMPLES
ssh preserving args When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and passes them to "$SHELL -c". This doesn't work as intended: ssh host touch 'hi there' # fails It creates 2 files, hi and there. Instead, do this: cmd=`shell-quote touch 'hi there'` ssh host "$cmd" This gives you just 1 file, hi there. process find output It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote: eval set -- `find -type f -print0 | xargs -0 shell-quote --` debug shell scripts shell-quote is better than echo for debugging shell scripts. debug() { [ -z "$debug" ] || shell-quote "debug:" "$@" } With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can. save a command for later shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are things the user can't pass through), you can do something like this: user_switches= while [ $# != 0 ] do case x$1 in x--pass-through) [ $# -gt 1 ] || die "need an argument for $1" user_switches="$user_switches "`shell-quote -- "$2"` shift;; # process other switches esac shift done # later eval "shell-quote some-command $user_switches my args" OPTIONS
--debug Turn debugging on. --help Show the usage message and die. --version Show the version number and exit. AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions. AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.16.3 2010-06-11 SHELL-QUOTE(1)
All times are GMT -4. The time now is 05:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy