Help with command - cp
I am wanting to use the CLI to copy some files from dirA to dirB. I want to exclude all hidden files. Will this command achieve it? :-- cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B Thanks, Lisi -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201401261426.18533.lisi.re...@gmail.com
Re: Help with command - cp
On 1/27/14, Lisi Reisz wrote: > I am wanting to use the CLI to copy some files from dirA to dirB. I > want to exclude all hidden files. Will this command achieve it? :-- > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B BTW, with GNU ls, -r is the same as -R, but doesn't require pressing :) Your command will exclude files and dirs beginning with period ('.'), in the directory /path/to/sourcedir/A/ but not "hidden" files in subdirectories (I note your -R/-r option). If you really are only copying files, then -r is not needed. Good luck Zenaan -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/caosgnsrqlg6oenr_tux2kttyjafy67tzqhuvc6hz0bx7fyn...@mail.gmail.com
Re: Help with command - cp
On 1/27/14, Zenaan Harkness wrote: > On 1/27/14, Lisi Reisz wrote: >> I am wanting to use the CLI to copy some files from dirA to dirB. I >> want to exclude all hidden files. Will this command achieve it? :-- >> >> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B > > BTW, with GNU ls, -r is the same as -R, but doesn't require pressing > :) > > Your command will exclude files and dirs beginning with period ('.'), > in the directory /path/to/sourcedir/A/ > but not "hidden" files in subdirectories (I note your -R/-r option). > If you really are only copying files, then -r is not needed. PS, I usually use /path/to/destinationdir/B/ , rather than /path/to/destinationdir/B , when "B" is meant to be a directory - it sometimes gives better error output, and also is a very good habit to get into if you start to use rsync. Which reminds me, rsync is often a better cp; I often use it locally, not only to copy between separate computers/hosts. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/caosgnsrvjvkeeglf5e2rhkkanyzzv1qnrtza_tki_3ua_72...@mail.gmail.com
Re: Help with command - cp
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2014-01-26 15:26, Lisi Reisz wrote: > I am wanting to use the CLI to copy some files from dirA to dirB. > I want to exclude all hidden files. Will this command achieve it? > :-- > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B Not quite. But close. You can get in trouble depending on how many items are in A and whether or not B exists. And it will only ignore hidden files if they are in A directly, not if they are in subdirectories. I prefer using rsync instead: $ rsync --dry-run -av --progress --exclude='.*' /path/to/A/ /path/to/B/ Notes: * Existing files in B will be overwritten. * You may want to look at the manpage to see what the options do. * The slashes after A and B are important. * The --dry-run option will show you what the command will do without actually performing the copy -- so you can check whether it behaves as expected. Leave it out to actually perform the copy. * You can add the --delete option if you want to completely synchronise the directories, as it will cause removal of files in B that are not in A (except those excluded -- see the man page). * If you only want to exclude hidden files in A itself (not in subdirectories), use --exclude='/.*' instead. > Thanks, Lisi - - Felix -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBCgAGBQJS5SBZAAoJELIY/ywn/GzG3EQQANJhaP/VLk2EcFQL+eTggCRi qTVWmbrSsMiaj2pBOrTelThGIVXsrWCukjkuOA/vxKKtMZJD2ZtLUIAi8HSj7zzw zLdnpQPmJgjecd8vxlw27pQkVgQfyDUOxXk4MZ9d3GQoFoZ3T21lHFfPWskZqJbL QqJ3ZrhYU4ijbmr7YBxGNiw/Ph5nc6FwihiU9DvcoNThJy+MlIklJJVAhMu+UaZ8 i9OOCsF7zAXxkbbk1bXjn+ni6PkiKD7AkTWrCQ/4vpa448cwZCth/v9p8akuniUu 7FserEDpwJhwdTInYWO7cBBXc2a9QDC5f/bCZ+eBbgpvrFBeiBt7f2ZStElMSWbY Gv7BQ8x3ZZPJf0H+47wN00OOEuIouOWL88FWFMNaERtc4JQsXU9C+0n/O9N8AW+/ QNMZsw8zNAr4Eu/SFt88SuIWVO/zSDCPrcG6xweEirdKE8uFXca26seTHluYusp0 xnfXSzpT21ERXn2wnNASf7WHsP9T+5hcP3V7h+0t0dwtI3vC84e+PKBGMvcl40ps QPjtybj2Dpz0u5sobgjnFN2RnguRRLbruTyvhcbb3LFZ69nORVJEFxzKEPAGmN2n up1OsHO4HGwRTexyI3i3C+FxKeI2SoqSBbmvHx1W+oUZCqaal7lOyB1M7aTXCp98 sCidWvwF7U1EUTeGwzKs =wAvY -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e5207b.4060...@obfusk.org
Re: Help with command - cp
On Sunday 26 January 2014 14:40:26 Zenaan Harkness wrote: > Your command will exclude files and dirs beginning with period > ('.'), in the directory /path/to/sourcedir/A/ > but not "hidden" files in subdirectories (I note your -R/-r > option). If you really are only copying files, then -r is not > needed. Thanks, Zenaan. No, I was sloppy, and just using the terminology of Konqueror: . I want to exclude everything hidden, directories, subdirectories and files. If I were doing this the laborious way, I would have hidden files hidden, and drag and drop over only the visible icons. I just thought that the CLI would be better. (I was born lazy!) I am a little afraid of rsync purely because I have never used it. Maybe this is the time to start. I have noted your preference for e.g. /home/lisi/ over /home/lisi . It would clearly be a good idea to get into the same habit. Thank you, Lisi -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201401261600.28036.lisi.re...@gmail.com
Re: Help with command - cp
On Sunday 26 January 2014 14:49:31 Felix C. Stegerman wrote: > On 2014-01-26 15:26, Lisi Reisz wrote: > > I am wanting to use the CLI to copy some files from dirA to dirB. > > I want to exclude all hidden files. Will this command achieve > > it? >> :-- > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B > > Not quite. But close. You can get in trouble depending on how > many items are in A and whether or not B exists. And it will only > ignore hidden files if they are in A directly, not if they are in > subdirectories. > > I prefer using rsync instead: > > $ rsync --dry-run -av --progress --exclude='.*' /path/to/A/ > /path/to/B/ > > > Notes: > > * Existing files in B will be overwritten. > * You may want to look at the manpage to see what the options do. > * The slashes after A and B are important. > * The --dry-run option will show you what the command will do > without actually performing the copy -- so you can check whether it > behaves as expected. Leave it out to actually perform the copy. > * You can add the --delete option if you want to completely > synchronise the directories, as it will cause removal of files in B > that are not in A (except those excluded -- see the man page). > * If you only want to exclude hidden files in A itself (not in > subdirectories), use --exclude='/.*' instead. Thank you, Felix. That is very helpful and clear. Your notes are very useful. As I said to Zenaan, it is obviously time for me to bite the bullet of rsync. It seems a significantly better tool for the purpose than cp. Lisi -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201401261605.52433.lisi.re...@gmail.com
Re: Help with command - cp
Sorry for sending this off-list, Gord. Resending to where it ought to have gone in the first place. On Sunday 26 January 2014 15:09:10 ghaverla wrote: > Your requirement (to skip hidden files and directories) is what is > usually required. > > But, as a generic rule, you can use the echo command to help with > analysing how the command line shell might expand a wild card. > > echo cp /path/to/src/* /path/to/dest > some_tmp_file > > If I do this on my home directory, I could a huge list as I have > too many files. Which is why I redirected the output to a file. > And looking in the file, I find that there are no hidden > directories or files copied. > > If we look at your command line, you have two switches -R and -p. > The -R turns on recursive copying, not only is every file > in .../sourcedir/A copied, every subdirectory of .../sourcedir/A, > and subdirectories of those, to the end of the file tree is copied. > The -p switch asks for the preservation of metadata: ownership, > groupship, and times. > > If you are the owner of the files under sourcedir/A and you are > also the owner of destinationdir/B, I would expect the ownership > and groupship to already be proper, and so it is only the file time > information which is being preserved. Preserve is important if > root is doing the copying. Thank you very much, Gord. Most helpful. I hadn't thought of using echo like that. I obviously need to work on my lateral thinking. :-( Lisi -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201401261613.31575.lisi.re...@gmail.com
Re: Help with command - cp
On Sun, 2014-01-26 at 14:26 +, Lisi Reisz wrote: > I am wanting to use the CLI to copy some files from dirA to dirB. I > want to exclude all hidden files. Will this command achieve it? :-- > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B Globbing lady! Yesno, it won't copy hidden files in A/, but it will copy files in A/foo_bar. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/1390752938.685.10.camel@archlinux
Re: Help with command - cp
On Sun 26 Jan 2014 at 16:05:52 +, Lisi Reisz wrote: > As I said to Zenaan, it is obviously time for me to bite the bullet of > rsync. It seems a significantly better tool for the purpose than cp. The Midnight Commander (mc) is worth considerating for the sort of job you described. See 'File Selection Mechanisms' at http://linuxgazette.net/23/wkndmech_dec97/mc_article.html -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/26012014164146.3f3a8cc09...@desktop.copernicus.demon.co.uk
Re: Help with command - cp
On Sunday 26 January 2014 16:53:17 Brian wrote: > On Sun 26 Jan 2014 at 16:05:52 +, Lisi Reisz wrote: > > As I said to Zenaan, it is obviously time for me to bite the > > bullet of rsync. It seems a significantly better tool for the > > purpose than cp. > > The Midnight Commander (mc) is worth considerating for the sort of > job you described. See 'File Selection Mechanisms' at > >http://linuxgazette.net/23/wkndmech_dec97/mc_article.html Thanks, Brian. Again, it was about time I looked at MC. It has, I know, many dedicated fans. I hadn't realised that it could do this kind of job. Lisi -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201401261702.44598.lisi.re...@gmail.com
Re: Help with command - cp
On Sun, 1/26/14, Lisi Reisz wrote: Subject: Re: Help with command - cp To: debian-user@lists.debian.org Date: Sunday, January 26, 2014, 10:05 AM As I said to Zenaan, it is obviously time for me to bite the bullet of rsync. It seems a significantly better tool for the purpose than cp. Lisi --- Maybe you'd find grsync gui less intimidating than cli? -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/1390766612.14687.yahoomailba...@web163404.mail.gq1.yahoo.com
Re: Help with command - cp
* Felix C. Stegerman wrote on 2014-01-26 at 15:49 (+0100): > On 2014-01-26 15:26, Lisi Reisz wrote: > > I am wanting to use the CLI to copy some files from dirA to > > dirB. I want to exclude all hidden files. Will this command > > achieve it? > > I prefer using rsync instead: > > $ rsync --dry-run -av --progress --exclude='.*' /path/to/A/ /path/to/B/ > > * The slashes after A and B are important. No, you only have to take care about the trailing slash of the source A. See rsync(1): A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name", but in both cases the attributes of the containing directory are transferred to the containing directory on the destination. In other words, each of the following commands copies the files in the same way, including their setting of the attributes of /dest/foo: rsync -av /src/foo /dest rsync -av /src/foo/ /dest/foo The trailing slash of the target directory B is irrelevant: $ mkdir -p foo/dir $ touch foo/file foo/dir/file foo/.hidden foo/dir/.hidden $ rsync -av --exclude='.*' foo target1 $ rsync -av --exclude='.*' foo target2/ The results are identical directories ./target1 and ./target2. Of course, both need not exist. Regards, Mathias -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20140126204815.ga29...@gmx.org
Re: Help with command - cp
On 26/01/14 14:26, Lisi Reisz wrote: I am wanting to use the CLI to copy some files from dirA to dirB. I want to exclude all hidden files. Will this command achieve it? :-- cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B Thanks, Lisi If you don't put a / after B it will copy all files to a file called B So your above cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B Should be cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B/ Also when using rsync, i use the following rsync -vrthiP --progress --stats source/ destination/ This also checks for and only updates changed files on any subsequent rsync from A to B Don't forget the / at the end, even rsync will copy everything to a file rather than the wanted directory if you miss of the / If you want to copy the folder A to the second source folder and keep the A name rsync -vrthiP --progress --stats /path/to/source/A /path/to/source/ No / after A and no B after the last source/ If you only want to rsync the contents of folder A to folder B then put a / after A :) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e5766f.7000...@yahoo.com
Re: Help with command - cp
* Mr Smiley wrote on 2014-01-26 at 20:56 (+): > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B > > If you don't put a / after B it will copy all files to a file > called B No, obviously not. $ mkdir src $ echo foo > src/file1 $ echo bar > src/file2 $ echo baz > src/.hidden1 $ [ -e ./target ] || echo "./target not found!" ./target not found! $ cp -Rp ./src/* ./target cp: target `./target' is not a directory $ cp -Rp ./src/* ./target/ cp: target `./target/' is not a directory $ [ -e ./target ] || echo "./target not found!" ./target not found! > So your above > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B > Should be > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B/ If the target directory *exists* the trailing slash will *not* be necessary: $ mkdir target1 target2 $ cp -Rp ./src/* ./target1 $ cp -Rp ./src/* ./target2/ Both directories are identical. There will be no *file* B! > Also when using rsync, i use the following > > rsync -vrthiP --progress --stats source/ destination/ > > This also checks for and only updates changed files on any > subsequent rsync from A to B > > Don't forget the / at the end, even rsync will copy everything to a > file rather than the wanted directory if you miss of the / That's not correct. In contrast to the slash trailing the *source*, the final slash trailing the *target* is completely irrelevant. See my other mail. Regards, Mathias -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20140126222437.ga8...@gmx.org
Re: Help with command - cp
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2014-01-26 21:48, Mathias Bauer wrote: > * Felix C. Stegerman wrote on 2014-01-26 at 15:49 (+0100): > >> On 2014-01-26 15:26, Lisi Reisz wrote: >>> I am wanting to use the CLI to copy some files from dirA to >>> dirB. I want to exclude all hidden files. Will this command >>> achieve it? >> >> I prefer using rsync instead: >> >> $ rsync --dry-run -av --progress --exclude='.*' /path/to/A/ >> /path/to/B/ >> >> * The slashes after A and B are important. > > No, you only have to take care about the trailing slash of the > source A. See rsync(1): > > A trailing slash on the source changes this behavior to avoid > creating an additional directory level at the destination. You can > think of a trailing / on a source as meaning "copy the contents of > this directory" as opposed to "copy the directory by name", but in > both cases the attributes of the containing directory are > transferred to the containing directory on the destination. In > other words, each of the following commands copies the files in the > same way, including their setting of the attributes of /dest/foo: > > rsync -av /src/foo /dest rsync -av /src/foo/ /dest/foo > > The trailing slash of the target directory B is irrelevant: > > $ mkdir -p foo/dir $ touch foo/file foo/dir/file foo/.hidden > foo/dir/.hidden $ rsync -av --exclude='.*' foo target1 $ rsync -av > --exclude='.*' foo target2/ > > The results are identical directories ./target1 and ./target2. Of > course, both need not exist. You're right. I always use trailing slashes on both sides, because that way both rsync and cp behave as I expect them to. > Regards, Mathias - - Felix -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBCgAGBQJS5YdqAAoJELIY/ywn/GzGUmsQAKlXbyJ8gEyVBMt5BfMrerTD QTCCJWXiANMgYgRJsSfqxIYvKarh/efFC58XrV5XB/gqy2ov6sEIjCa7ZANRwk6j hwVwUDz3et4MWaeoYpFIAn01U33UZj1RxpO2EfEXF8if7nSe87ctjeC/ulmuWDHJ nsTNn9vN3mEigBFAWDVQ4sBIS+0tQNhHkFUUJTcAU98qvbUjNrynj8EsL0MNoIti 4bw6KbRU1ApCOe522G8q7pPHac9EXKp8DZvnjnKbC92VaI6JxqvWQ9b5IDoQ7y7W Zbc2leTiFhJHfPz0F9dojxMTmO3Eb2Y4+nGisUBveq3WLa2lpQsIwJSfZE3lZ7Zf bAllluz3hVTbwyGV9hRT+qocVLEL1Ya+UYB5ktnYpIOZ/eTqTJcDhvx0ZXrojceY 1c8V2a1Jf0Ht/+4yyuBie156pQn+8bps7EdFf3rrJhN4Te5UrlOYg095V4Cur/8d ZgQ4Jt32RE9ri/rELwsYJ1HbuP3VR7I0RablHHwzlSCWO3JNk8OCmgZg8Y0IBSD0 qwa2X8WOtqvvsQzBrcUIJ0FXOJ6Im64eoNf334nUTvlZIYE5rV2sm9dMvSiMlVLS sug0dxczH6/jHtIkH44ayrRylrNzLCwyK2fH3ykzotSBJJNo9K8ZfQb6HpFOVXtM EH1ChAvkDi8SXIYqnOuD =VhGP -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e58773.8090...@obfusk.org
Re: Help with command - cp
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2014-01-26 23:24, Mathias Bauer wrote: > * Mr Smiley wrote on 2014-01-26 at 20:56 (+): > >>> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B >> >> If you don't put a / after B it will copy all files to a file >> called B > > No, obviously not. > > $ mkdir src $ echo foo > src/file1 $ echo bar > src/file2 $ echo > baz > src/.hidden1 $ [ -e ./target ] || echo "./target not found!" > ./target not found! $ cp -Rp ./src/* ./target cp: target `./target' > is not a directory $ cp -Rp ./src/* ./target/ cp: target > `./target/' is not a directory $ [ -e ./target ] || echo "./target > not found!" ./target not found! It does if there's only one file in A and B does not exist. $ mkdir A; echo HI >> A/foo $ cp -a A/* B $ cat B HI > [...] Regards, Mathias - - Felix -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBCgAGBQJS5ZMoAAoJELIY/ywn/GzG8aoP/RAwuBJoYttXvEGzhg4HGtMq B/8ZlYQHxkSFBYUzmC6QBeJqJTidrRdt/XtIxTNp4kaS4iF7Hw8zGTdNvhNvpXLh 5Oa+3Cavj2fIYBUGO6d4x/2y+V6TE93/WHhKsSqSePfStMxC4YDTlwVggDCYXlOF izU475gmvVag684q2VxaoQdSkr5kQDtITDeQBabX8y6EO1d/MXP8NWKcLsAS/8wr BgWxDDuF7yGuwC4+dXcWJp2JStQ0LB+ba1ITk5f6PQchS8ccf7/2u1uSX/8ORWYL 3gJgWMsgNY52XCOefvvOTKWqwGYWPI7HiJ+q9JInGShnURgp4PMt65V+MN8HQHDQ 8WSCJu3g9JnCpp8EJzdi3T3L0iJCyvJN12gteyep6Su31jmwMJizC71PpOgZwKzP 7xizwcOii6F0dkxxaIO7K6ntwrNWePIj89NKEHGMCeoxjcoSWJ7+Z7MNmSRc7Yor uPt9AzPq+fjpfUcRrWxLokIDFD9GL6ZTeZ8WpVEOI1PTSt4oiZpJKceWRWZWNMU2 o+cp1eqDvDHm45Pp6nA1oNOxfbTilsFySzuDubdUB7ZGV3Z1N7hHzAUgn8f2/hu1 UouMBC90DfswfAZomXHMRLD4Tth81ZzACKqPf4EhCiO1qFuOwJRsNdxDS+hq6ALI sq0KEVZrPnmj75ZGnDL4 =CMk1 -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e59330.4020...@obfusk.org
Re: Help with command - cp
On 1/27/14, Go Linux wrote: > On Sun, 1/26/14, Lisi Reisz wrote: >> As I said to Zenaan, it is obviously time for me to bite the bullet of >> rsync. It seems a significantly better tool for the purpose than cp. > Maybe you'd find grsync gui less intimidating than cli? I've used one or two rsync GUIs. I find with those I have taught that command-line competency translates almost automatically to GUI competency (or confidence), but not always the other way around. However I do occasionally run a GUI app to view settings of jackd for example, to make sure that what I'm looking at in the config matches my "GUI" understanding, and some GUIs provide more informative "comments" (pop ups whatever), but sometimes vice versa. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/caosgnssdwj82dja6siia5fwacsetfcceqitqvxn6drp6xwz...@mail.gmail.com
Re: Help with command - cp
On 1/27/14, Mathias Bauer wrote: > * Mr Smiley wrote on 2014-01-26 at 20:56 (+): > >> > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B >> >> If you don't put a / after B it will copy all files to a file >> called B > > No, obviously not. true >> So your above >> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B >> Should be >> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B/ > > If the target directory *exists* the trailing slash will *not* be > necessary: true and to state what should be obvious: if the target directory does *not exist*, then the trailing slash will, if you end up copying just one file, cause an error to be displayed rather than the wrong action to occur. >> Also when using rsync, i use the following >> >> rsync -vrthiP --progress --stats source/ destination/ >> >> This also checks for and only updates changed files on any >> subsequent rsync from A to B >> >> Don't forget the / at the end, even rsync will copy everything to a >> file rather than the wanted directory if you miss of the / > > That's not correct. In contrast to the slash trailing the > *source*, the final slash trailing the *target* is completely > irrelevant. See my other mail. True. But it does encourage (to my experience) thinking a little bit more about what I'm doing, because I do sometimes still use cp etc. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/caosgnsr0w9yjycmuq0zshjip+dcerpltcutfw7qecsjxvy7...@mail.gmail.com
Re: Help with command - cp
On Sun, 1/26/14, Lisi Reisz wrote: As I said to Zenaan, it is obviously time for me to bite the bullet of rsync. It seems a significantly better tool for the purpose than cp. Some time ago I was using "cp" for bulk file copying, but was having some issues with maintaining the original permissions and such. That was quite a while ago and may have been a result of PEBKAC, and not "cp" itself. heh. After some not-so-gentle nudging from my computing guru moved me to rsync. Nowadays my use of "cp" is pretty much limited to very basic stuff and leave the heavy lifting to rsync. No looking back ... Jeff -- hangout: ##b0rked on irc.freenode.net diversion: http://alienjeff.net - visit The Fringe quote: "The foundation of authority is based upon the consent of the people." - Thomas Hooker -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e5a216.3040...@charter.net
Re: Help with command - cp
* Felix C. Stegerman wrote on 2014-01-26 at 23:58 (+0100): > On 2014-01-26 23:24, Mathias Bauer wrote: > > * Mr Smiley wrote on 2014-01-26 at 20:56 (+): > > > > > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B > > > > > > If you don't put a / after B it will copy all files to a > > > file called B > > > > No, obviously not. > > > > [...] > > It does if there's only one file in A and B does not exist. > > $ mkdir A; echo HI >> A/foo > $ cp -a A/* B > $ cat B > HI Yes, but ... come on, that's a rather trivial shell expansion! By the way, don't you consider it a little bit strange to change the original problem conditions *afterwards*? * Lisi Reisz wrote on Sun, 26 Jan 2014, at 14:26 (+): > I am wanting to use the CLI to copy some files from dirA to > dirB. I want to exclude all hidden files. Read ... file*S*. Regards, Mathias -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20140127010425.ga31...@gmx.org
Re: Help with command - cp
On 1/27/14, Mathias Bauer wrote: > * Felix C. Stegerman wrote on 2014-01-26 at 23:58 (+0100): > >> On 2014-01-26 23:24, Mathias Bauer wrote: >> > * Mr Smiley wrote on 2014-01-26 at 20:56 (+): >> > >> > > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B >> > > >> > > If you don't put a / after B it will copy all files to a >> > > file called B >> > >> > No, obviously not. >> > >> > [...] >> >> It does if there's only one file in A and B does not exist. >> >> $ mkdir A; echo HI >> A/foo >> $ cp -a A/* B >> $ cat B >> HI > > Yes, but ... come on, that's a rather trivial shell expansion! > By the way, don't you consider it a little bit strange to change > the original problem conditions *afterwards*? > > * Lisi Reisz wrote on Sun, 26 Jan 2014, at 14:26 (+): > >> I am wanting to use the CLI to copy some files from dirA to >> dirB. I want to exclude all hidden files. > > Read ... file*S*. Now come on ... there is no reduction in functionality by appending '/', and yet there is the advantage of training the fingers in a way that _actually_helps_ in certain potential other cases. That's all I and others are saying. I personally have been bitten at least twice in 20 years by _not_ appending '/' after my destination _directory_name_ ... Henceforth we shall limit all responses to the question, only the question, and nothing but the OP's precise question! Or else! All contributors beware. :) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/caosgnsra80oz8pdrlf6+d9advwhohznhvhq4vg2tsoudu14...@mail.gmail.com
Re: Help with command - cp
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2014-01-27 02:04, Mathias Bauer wrote: > * Felix C. Stegerman wrote on 2014-01-26 at 23:58 (+0100): > >> On 2014-01-26 23:24, Mathias Bauer wrote: > >>> * Mr Smiley wrote on 2014-01-26 at 20:56 (+): >>> > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B If you don't put a / after B it will copy all files to a file called B >>> >>> No, obviously not. >>> >>> [...] >> >> It does if there's only one file in A and B does not exist. >> >> $ mkdir A; echo HI >> A/foo $ cp -a A/* B $ cat B HI > > Yes, but ... come on, that's a rather trivial shell expansion! By > the way, don't you consider it a little bit strange to change the > original problem conditions *afterwards*? > > * Lisi Reisz wrote on Sun, 26 Jan 2014, at 14:26 (+): > >> I am wanting to use the CLI to copy some files from dirA to dirB. >> I want to exclude all hidden files. > > Read ... file*S*. > > Regards, Mathias You're absolutely right *in this context*. But if you're not aware that the command will behave differently when there's only one file, you may run into trouble later on when you use it in a different context. That's why I mentioned it. So people don't expect it to work in the same way with *any number* of files. You'll also get different results if there are *no files* (unless you use nullglob). - - Felix -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBCgAGBQJS5bXcAAoJELIY/ywn/GzG5GQP+gOx4MFOs+Gee5XKk4E7Xkwn nkem4A0jMvHpIVWIm1+f79D/VoV93oyM4EbL/ppeRY3zco1TjfxWMwjxB2tLNrEM y58q2+n0/4wsrtyc5CKFRAtw2xGNhkZLezXMBk0sm62zlAXt5qQDUgUMqLfyl+nn Ha0eR9tVWpEiLQVi0TZl7Mn/TvKwvN2DlcrOp5urgB8q6CerZiUGcxteblQSkRQm 8h2a8q4sNeT0m/gBtxCtgG/0l4FOC0tE9swhadwHNIUDIA2W0Q3NWR4OpirVHhcF 7Mjlmt8IzEhOWh6Sq0iWd3Therg/dZsI2VXfxLyP/OpYEnIOwoHRv0HUwE8A+I1N jaE7y0oHeT3oT0/9Og6ii5cxSFUixRVKVkIr0oaw4CEhDWm8rvyNNPUM/mlP0wlV raslS5e9wSko3WqzrfoCN4jREC9EoYIrsjssfiQ1dqBVZVXoGOcEC1UabcLM9rSq QshUQXGmb/oDDLXQVgtOMP1oCCJ3RNj7zgtqiiRF+9B9VrqRP5Shn3PAAFT379nq uMJ6YSP5KOquRXs4b+iuM6KfwlNKgaxJKP9EgvoNoFMxO+IzO7LUQnNaC5L250lJ /Vo3Q41Yo3ia9QFiE/XoNy5iOBjPnm8W8izSr+E7HWFwad7xvZiEFHfxuKKZ1vw9 8z/KqTSjHMSEQgOjtV/E =nkeh -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e5b5e3.4040...@obfusk.org
Re: Help with command - cp
On Sun, 2014-01-26 at 23:24 +0100, Mathias Bauer wrote: > If the target directory *exists* the trailing slash will *not* be > necessary On Mon, 2014-01-27 at 12:44 +1100, Zenaan Harkness wrote: > and yet there is the advantage of training the fingers Using the tab-key a / is automatically attached. $ cp Do + tab-key = $ cp Downloads/ $ cp Downloads/ De + tab-key = $ cp Downloads/ Desktop/ I only would remove a /, if there is a reason to do so. IOW depending to what I want, I would run $ cp Downloads/* Desktop/ $ cp -r Downloads/ Desktop/ just because I use the tab-key. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/1390801738.688.6.camel@archlinux
Re: Help with command - cp
Your requirement (to skip hidden files and directories) is what is usually required. But, as a generic rule, you can use the echo command to help with analysing how the command line shell might expand a wild card. echo cp /path/to/src/* /path/to/dest > some_tmp_file If I do this on my home directory, I could a huge list as I have too many files. Which is why I redirected the output to a file. And looking in the file, I find that there are no hidden directories or files copied. If we look at your command line, you have two switches -R and -p. The -R turns on recursive copying, not only is every file in .../sourcedir/A copied, every subdirectory of .../sourcedir/A, and subdirectories of those, to the end of the file tree is copied. The -p switch asks for the preservation of metadata: ownership, groupship, and times. If you are the owner of the files under sourcedir/A and you are also the owner of destinationdir/B, I would expect the ownership and groupship to already be proper, and so it is only the file time information which is being preserved. Preserve is important if root is doing the copying. Gord -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20140126080910.208c8f5e@newmain.materia
Re: Help with command - cp
On 27/01/2014 3:05 AM, Lisi Reisz wrote: >> * The --dry-run option will show you what the command will do > As I said to Zenaan, it is obviously time for me to bite the bullet of > rsync. It seems a significantly better tool for the purpose than cp. Don't be scared of rsync, it works a great deal like cp and if you do use cp, then I think the best habit is to always use "cp -p" to keep permissions or "cp -a" for a full archive copy. The --dry_run option of rsync is a great test to make sure you get it right first; there are lots more options too, for all sorts of reasons (including consideration of not crossing file systems or handling of symbolic links). Cheers A. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e7af0c.9080...@affinityvision.com.au
Re: Help with command - cp
On 28/01/14 13:22, Andrew McGlashan wrote: On 27/01/2014 3:05 AM, Lisi Reisz wrote: * The --dry-run option will show you what the command will do As I said to Zenaan, it is obviously time for me to bite the bullet of rsync. It seems a significantly better tool for the purpose than cp. Don't be scared of rsync, it works a great deal like cp and if you do use cp, then I think the best habit is to always use "cp -p" to keep permissions or "cp -a" for a full archive copy. The --dry_run option of rsync is a great test to make sure you get it right first; there are lots more options too, for all sorts of reasons (including consideration of not crossing file systems or handling of symbolic links). Cheers A. Also, if rsync gets stopped for any reason, ie your computer crashes or the remote location disconnects, it will restart from where it stopped using the same command line used previously. I believe with cp if something goes wrong you have to start from the very beginning overwriting all the already copied files, unless you exclude them. :) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e7e5e8.4040...@yahoo.com
Re: Help with command - cp
Le 26.01.2014 15:26, Lisi Reisz a écrit : I am wanting to use the CLI to copy some files from dirA to dirB. I want to exclude all hidden files. Will this command achieve it? :-- cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B Thanks, Lisi Just a note, too late but it could help later too, for another problem. What I would have made is a quick and dirty method: first a classic copy ( I do not know rsync too ) $cp -r ~/foo ~/bar And then: $ cd ~/bar && rm `find -name '.*'` Indeed, it have really poor performances (in term of computer ones), since some files are first copied and then deleted, but it should work ( did not tried, actually ) and does not require any learning except the very basic use of find, in case you do not already know it. Could be made in a better way of the same direction, maybe by using find to select stuff to copy, but I take for sure that the lines will be quite more complex, as find is a really powerful tool, but it's man is not really clear about how to do stuff which could be considered basic. I can remember having some pain with it for more complex things like excluding some directories and only selecting files with different extensions. Note that folders . and .. can not be removed so you will warnings, but those are simply warnings. This is just another (and a dirty one) way to do the thing you needed :) -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e4de5c5c8e3eb309df89ccd56985f...@neutralite.org
Re: Help with command - cp
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2014-01-29 10:43, berenger.mo...@neutralite.org wrote: > > > Le 26.01.2014 15:26, Lisi Reisz a écrit : >> I am wanting to use the CLI to copy some files from dirA to dirB. >> I want to exclude all hidden files. Will this command achieve >> it? :-- >> >> cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B >> >> Thanks, Lisi > > Just a note, too late but it could help later too, for another > problem. > > What I would have made is a quick and dirty method: first a classic > copy ( I do not know rsync too ) $cp -r ~/foo ~/bar > > And then: $ cd ~/bar && rm `find -name '.*'` Find is indeed very useful, but that's probably a bad idea. You'll get into trouble with filenames containing spaces for example. find will also (as you point out) try to remove the current directory ('.'). And you won't remove hidden directories because you didn't call rm with '-r', which is a good thing since it would have removed said current directory. If you really want to use find, use something like: $ find -depth -name '.?*' -exec echo rm -rv -- {} \; Which will not match '.' because it expects at least one character after the dot, will handle filenames correctly, and remove directories recursively. Once you remove the 'echo' of course. I left it in there so you can run it to see what would be removed. Of course, in this case you should probably use rsync instead. > Indeed, it have really poor performances (in term of computer > ones), since some files are first copied and then deleted, but it > should work ( did not tried, actually ) and does not require any > learning except the very basic use of find, in case you do not > already know it. Could be made in a better way of the same > direction, maybe by using find to select stuff to copy, but I take > for sure that the lines will be quite more complex, as find is a > really powerful tool, but it's man is not really clear about how to > do stuff which could be considered basic. I can remember having > some pain with it for more complex things like excluding some > directories and only selecting files with different extensions. > > Note that folders . and .. can not be removed so you will warnings, > but those are simply warnings. > > This is just another (and a dirty one) way to do the thing you > needed :) - - Felix -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBCgAGBQJS6RGLAAoJELIY/ywn/GzGPfwQALH7Rslw4LWZyOrR71hqXq0T y+XWTHS6eDVZDgn8JCh70Bky+DHvvYuqpu+VerJec0BKZSXz5OU+YeDY3wELp+AR TXPt5/7wgrxATspi1t356kWx47Cp0BOmS3AX/16fStV4tQ5YX6r/bCUKUMbtVlU7 bHozq0L0iFi6rysnvZFWZpeZIDTFqo7BTRs05ggd/iuWZALm3eYlbsQJ2ep7gb2H yrAvt0wy1pTN8vGjtZiZcIqy9CHhNXJ7w3qAz0TLrAJ3+KvpDmMiJxq+a2dPc4Nu rJAmJFu6YX1hEzTpCV73vV/i7xTI11zJISnxS3QPdaawpNsI0wbAQNv0x6xmZyVo 8Bw7Gr26/LJm7N18cyknSKCEoenCOP6I/Q1sijkloORMWE9uA8s+5BLBYLvXXrsT XjuTTYg8igpy/h6d4Cl1XjZRtJnC1zmDZwGRep6OCwzw9qNGwyq9Xy+0vn9CzJ+P y4U5YKDjHWC3NHdrOCZp1Kajo2viZDZ3KMz5t7hh3RIwpcwkdTjCiq/bea3rDAqv rClMVRKqz65uGNNqiTmnguSb0gSDtfaEWshpGv9em5DUyArp+NZR9ZTn+ggLyOi/ tnrs6zTAuth9gnplVWgFQtmvJ9oBLHLqwHlGxbeqd9IWqiLhik2iMcOPMvwGYukf TVe/Kf5MUp0Gi6e5aYvO =bvG0 -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52e91193.1010...@obfusk.org
Re: Help with command - cp
On 1/30/14, Felix C. Stegerman wrote: > On 2014-01-29 10:43, berenger.mo...@neutralite.org wrote: >> And then: $ cd ~/bar && rm `find -name '.*'` > > Find is indeed very useful, but that's probably a bad idea. You'll > get into trouble with filenames containing spaces for example. > If you really want to use find, use something like: > > $ find -depth -name '.?*' -exec echo rm -rv -- {} \; > > Which will not match '.' because it expects at least one character > after the dot, will handle filenames correctly, Does find do the filename-with-space escaping for us with those {braces}? (I don't have access to man pages ATM sorry). -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/CAOsGNSRx61s6E7=hu2runm3vxj8wse4yrumq1wpf5ihabe-...@mail.gmail.com
Re: Help with command - cp
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 2014-01-30 01:51, Zenaan Harkness wrote: > On 1/30/14, Felix C. Stegerman wrote: >> On 2014-01-29 10:43, berenger.mo...@neutralite.org wrote: > >>> And then: $ cd ~/bar && rm `find -name '.*'` >> >> Find is indeed very useful, but that's probably a bad idea. >> You'll get into trouble with filenames containing spaces for >> example. > >> If you really want to use find, use something like: >> >> $ find -depth -name '.?*' -exec echo rm -rv -- {} \; >> >> Which will not match '.' because it expects at least one >> character after the dot, will handle filenames correctly, > > Does find do the filename-with-space escaping for us with those > {braces}? (I don't have access to man pages ATM sorry). I tested it with a file named ".foo bar baz", so yes ;-) - - Felix -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBCgAGBQJS6tWUAAoJELIY/ywn/GzG0LMP/AgEkUX4UFzeJVngwA98diLr 1TG8TAFN60StfUro32EZtZEiCvwXxlWQRe5QPwV4MRIzXlfPYsLJ5E2AwxPxbS/C O1kJaVjL4D/7SyHyNdNzdigvichVLGb7xaG9Uq0rGohytTQ+mer7umlfVMo5RRMg dgc/QaoqnTcW79Vl4vo4Ol8xfA9TRm8iTS3N0NPL4wSHE5UDfWvgiH53XgdBOso8 yQ5K4YRksD/AdypW5nWwRzUTc17UAWYRwL83PLjfep6D5e1l5CTPg5LPB94EBIuH 58Kvu43+1A2V72aPM3QPazE0HG36t97+5PLAxo5npk+s8TJRnoYBIvYdFPQ7vVvb 0c5l4SEtIMzXthoHMKYCNBx5juXEOjlmEJjSPgnWfoRpTJ/VdzGaf+IDeKoC/8Y0 WiFGX0ucx5/8NI2J+i7eJa1CpWJ3k7+ILcjpd7D8syQRY0A6Llp0+YssP3/wL3Yb h9kgRcU/q2VAyjmB2/+uzH0cquss4y4UhjM2rwwpxEa46lg3Vd7vQi19xpHSqdTT kL7Yhu3y2jY0g6IkDexoF0Q0YbDb3mK7Io8Sl4jzpxcJ3D3FEps7u6GtZM1ZMgaZ j02P6GdfoVXrr4h+d5PytKDUNYFrTuEAW68jo5z7Xp0c1ZXtQiLCXmYZ2puc9J6u wOFHGcnWBhMLt83VfAu+ =wlLC -END PGP SIGNATURE- -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/52ead59c.6060...@obfusk.org
Re: Help with command - cp
On Sun, Jan 26, 2014 at 9:40 AM, Zenaan Harkness wrote: > > BTW, with GNU ls, -r is the same as -R, but doesn't require pressing > :) What do you mean by "GNU ls"? The ls provided by coreutils? If it is, then "-r" mean "reverse the sort order" and "-R" means "recurse through subdirectories". -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/CAOdo=Sxo6W9AduXYP6YG4OBp1n=68_kPDa+BRvUTVfc=uu4...@mail.gmail.com
Thanks! Re: Help with command - cp
On Sunday 26 January 2014 14:26:18 Lisi Reisz wrote: > I am wanting to use the CLI to copy some files from dirA to dirB. > I want to exclude all hidden files. Will this command achieve it? > :-- > > cp -Rp /path/to/sourcedir/A/* /path/to/destinationdir/B I have been away from my computer for a while, and have come back to a most generous number of answers. Individual thank-yous for each to the list could get tiresome for everyone else, so thank you, all of you. I really appreciate it, and have much to chew on. Lisi -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/201401262304.24298.lisi.re...@gmail.com