LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-30-2010, 09:06 AM   #1
ppj
LQ Newbie
 
Registered: Nov 2010
Posts: 4

Rep: Reputation: 0
Delete a file from different dir without using cd


Hi,

we assume that we have 2 folders with the name 1 and 2 .

The folder 2 is inside 1 .

Also, in folder 2 we have file with name "file.txt".

And we are in folder 1 .

How can we delete the file.txt in one command line ?

I mean without using the code below:


Code:
cd 2
rm -f file.txt
cd ..
 
Old 11-30-2010, 09:08 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Give the path to the file? For example, "rm 2/file.txt"..
 
1 members found this post helpful.
Old 11-30-2010, 09:09 AM   #3
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Code:
rm 2/file.txt
 
1 members found this post helpful.
Old 11-30-2010, 09:10 AM   #4
smccain
LQ Newbie
 
Registered: Jul 2008
Distribution: CentOS
Posts: 6

Rep: Reputation: 1
howsabout:
rm -f 2/file.txt
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Read file names in a Dir and its Sub Dir in Perl sagarkha Programming 2 04-28-2010 04:58 PM
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 09:40 PM
Recursive Delete DIR and Sub Dir with CONTENTS jCash Linux - Newbie 1 05-14-2007 05:54 PM
delete oldest file in dir. by c program hitesh.sharma84 Linux - Kernel 1 05-02-2007 10:18 AM
I Can't Delete a DIR carlosinfl Linux - General 2 10-19-2005 07:44 AM


All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration