Thread: Unix/Linux command question regarding relative_to_home pathnames?

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    23

    Unix/Linux command question regarding relative_to_home pathnames?

    Assume that you are NOT currently in your home directory. what command i should enter to copy all files my home directory beginning with the letter 'a' to the current directory by Using a relative-to-home pathname???

    I tried many, but it's not working
    i tried cp -p ~/home/ [a] *
    or
    cp a* ~/home/username
    or
    cp ../home/username [a]*

    etc etc
    not working

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    It depends on shell, but ~ is typically one's home directory and . (dot) is typically the current working directory.

    So

    cp ~/a* .
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    23
    Quote Originally Posted by grumpy View Post
    It depends on shell, but ~ is typically one's home directory and . (dot) is typically the current working directory.

    So

    cp ~/a* .
    thanks man it finally worked...but just one more question
    i want to delete all files that have filenames starting with'labtest', except 'labtest' itself (Delete all files starting with 'labtest'
    followed by one or more characters).
    i tried rm labtest[!labtest?]*
    rm labtest *[!labtest]
    rm labtest[!labtest]
    rm labtest [!labtest]*
    rm labtest[!]*
    none of em seem to be working

  4. #4
    Registered User
    Join Date
    Jan 2013
    Posts
    23
    Quote Originally Posted by blackendstars View Post
    thanks man it finally worked...but just one more question
    i want to delete all files that have filenames starting with'labtest', except 'labtest' itself (Delete all files starting with 'labtest'
    followed by one or more characters).
    i tried rm labtest[!labtest?]*
    rm labtest *[!labtest]
    rm labtest[!labtest]
    rm labtest [!labtest]*
    rm labtest[!]*
    none of em seem to be working
    never mind...i found it
    it's rm labtest?*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unix Command Interpreter Help
    By ashford74 in forum C Programming
    Replies: 14
    Last Post: 09-26-2008, 03:28 AM
  2. unix `ls' command in C program
    By Moony in forum C Programming
    Replies: 3
    Last Post: 06-28-2006, 10:00 AM
  3. CUT command of UNIX IN C
    By bulbulred in forum C Programming
    Replies: 4
    Last Post: 05-28-2006, 09:13 AM
  4. UNIX (Linux, BSD, etc) Programming :: UNIX
    By kuphryn in forum Linux Programming
    Replies: 6
    Last Post: 04-01-2004, 08:44 PM
  5. unix command
    By axon in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-22-2004, 12:35 PM