#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0

    Question Delete a file from different dir without using cd


    Hello,

    i want to delete the name.txt file from a folder with name FOL.

    But i do not want to use the first command , the cd .

    Code:
    cd \FOL
    
    rm -f name.txt
    *the -f is force remove


    i would like the above to be like this :

    Code:
    rm -f name.txt from FOL folder
    Any help please ..

    Thank you very much .
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,410
    Rep Power
    1871
    Like

    rm /path/to/your/file.txt
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    7
    Rep Power
    0
    sorry but i cannot understand you answer.

    for example, 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 ..
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2007
    Location
    Zografos, Greece
    Posts
    52
    Rep Power
    10
    Like he said:

    rm -f /path/to/file.txt

    for example, if you have structure like:

    /home/user/a/b/file.txt

    assuming you're in folder a, you can type:

    rm -f b/file.txt

IMN logo majestic logo threadwatch logo seochat tools logo