PDA

View Full Version : Unix/Linux command question regarding relative_to_home pathnames?



blackendstars
02-07-2013, 05:24 PM
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

grumpy
02-07-2013, 05:32 PM
It depends on shell, but ~ is typically one's home directory and . (dot) is typically the current working directory.

So

cp ~/a* .

blackendstars
02-07-2013, 05:52 PM
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

blackendstars
02-07-2013, 06:04 PM
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?*