|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I know that rm -i, asks a user before removing a file. What I need to accomplish is removing files from a different directory without switching to that directory. Example: I'm currently in directory dog and I want to remove all the files of a certain name in directory cat, but from within the dog directory. Please help.
|
| Sponsored Links | |
|
|
|
#2
|
|||
|
|||
|
use the full path Code:
rm /foo/bar/cat/other.file |
| Sponsored Links | ||
|
|
|
#3
|
||||
|
||||
|
Do you mean: Code:
cd dog rm -i /path/to/cat/pattern-to-be-removed* |
|
#4
|
|||
|
|||
|
I'll try this. ![]() ---------- Post updated at 10:47 PM ---------- Previous update was at 08:39 PM ---------- Ok I have to write a script to make this work: Code:
!#/bin/bash read -p "Enter week you would like to delete files: " $num rm -i /week$num/smiley* not sure why it doesn't work. I'm working from a week5 directory and it tells me that the directory doesn't exists. Last edited by Scott; 09-04-2010 at 05:58 AM.. Reason: Code tags, please... |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
the first line should be Code:
#!/bin/bash and your read statment should look like this -- no $ in the variable name Code:
read -p "Enter week you would like to delete files: " num |
| The Following User Says Thank You to frank_rizzo For This Useful Post: | ||
smiley76112 (09-04-2010) | ||
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Unless you're on a very special system, rm /week$i... probably won't work, if you need to access the week5's parent directory, use ..(double .). Here are a few examples: Code:
week5$ ls [list of files inside week5 directory] week5$ ls .. [list of files in the parent folder] week5$ ls ../week3 [list of files inside week3 directory, relatively from week5] week5$ cd .. [Go up to the parent] parent$ Last edited by tukuyomi; 09-04-2010 at 10:17 AM.. Reason: Formating |
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| remove .nfs and .swp files | northwest | Shell Programming and Scripting | 1 | 09-24-2009 11:29 PM |
| how to remove the files along with its link files | Ramesh_srk | UNIX for Advanced & Expert Users | 1 | 07-02-2009 06:22 AM |
| compare two files and to remove the matching lines on both the files | shellscripter | Shell Programming and Scripting | 4 | 06-20-2009 08:48 AM |
| Remove ^M (CR) from Unix Files | acheepi | Shell Programming and Scripting | 7 | 07-18-2005 09:28 AM |
| remove files | Nisha | Shell Programming and Scripting | 7 | 06-26-2002 12:04 AM |
|
|