Unix/Linux command question regarding relative_to_home pathnames?

This is a discussion on Unix/Linux command question regarding relative_to_home pathnames? within the Linux Programming forums, part of the Platform Specific Boards category; Assume that you are NOT currently in your home directory. what command i should enter to copy all files my ...

  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,259
    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%.

  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, 07:44 PM
  5. unix command
    By axon in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 02-22-2004, 11:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21