Find the answer to your Linux question:
Results 1 to 10 of 10
How can i delete the following three files “abc1.dat”, “abc2.txt”, and “abc3.bat” but not “abc4.tex” (Note: use only one shell command)...
  1. #1
    hhh
    hhh is offline
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5

    deleting files on shell

    How can i delete the following three files “abc1.dat”, “abc2.txt”, and “abc3.bat”
    but not “abc4.tex” (Note: use only one shell command)

  2. #2
    Linux Newbie radoulov's Avatar
    Join Date
    Sep 2007
    Posts
    111
    Homework?

    Code:
    rm abc[1-3].[bdt][ax]t
    Or better (assuming bash):
    Code:
    shopt -s extglob
    rm abc[1-3].@([bd]at|txt)
    The first example will remove abc.bxt, abc.dxt and abc.tat also

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    This sounds a bit like a homework question, which we're not allowed to answer.

    I will say, however, that most commands take in a list of arguments, rather than just a single one. This is often indicated in a man page by "...". For instance, if we run "man rm", we see this at the top:
    Code:
    SYNOPSIS
           rm [OPTION]... FILE...
    This means that rm takes in any number of (optional) options, followed by any number of files.

    I suggest you consider how to use this.
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    hhh
    hhh is offline
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5
    my command is
    rm -ri abc*

    but i this command is not true because i must do it in one command this is my problem

    ***
    shopt -s extglob
    rm abc[1-3].@([bd]at|txt)

    ****
    rm abc[1-3].[bdt][ax]t

    couldn't run these with ssh

  5. #5
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Quote Originally Posted by hhh View Post
    shopt -s extglob
    rm abc[1-3].@([bd]at|txt)

    ****
    rm abc[1-3].[bdt][ax]t

    couldn't run these with ssh
    Do you mean secure shell, or sh? Ssh is for remoting another machine. Sh is to call a script. If you are putting these in a script you must format the script properly by using a shabang #!/bin/bash at the start.

  6. #6
    hhh
    hhh is offline
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5
    i acces our teachers machine via ssh, i solve my problem rm abc[1-3]* command,
    i tried o say, i must use and run simply bash command because i am really new linux user and programmer

  7. #7
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    Are you using the BASH shell when you login via ssh? I don't really understand you. Is this now working?

  8. #8
    hhh
    hhh is offline
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5
    yes, bash shell

    (i said again i am extremelly new about linux)

  9. #9
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    If these commands are not working, can you post back the errors you are getting?

  10. #10
    hhh
    hhh is offline
    Just Joined!
    Join Date
    Oct 2007
    Posts
    5
    sorry i have tried again and i see both of the commands run succesfully!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...