Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: cp and mv command - nuanced instructions

  1. #11
    Join Date
    Feb 2008
    Location
    Pelican Bay Correctional
    Beans
    Hidden!

    Re: cp and mv command - nuanced instructions

    Quote Originally Posted by fromite View Post
    Know of any good educational references?
    Well. since you asked

    Various Linux Guides I have collected:
    http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
    http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
    http://tldp.org/HOWTO/Bash-Prompt-HOWTO/
    http://www.gnu.org/software/bash/man...ode/index.html
    http://www.grymoire.com/Unix/Sh.html
    http://www.grymoire.com/Unix/Sed.html
    http://tldp.org/LDP/abs/abs-guide.pdf
    http://www.tldp.org/LDP/abs/html/
    http://mywiki.wooledge.org/BashFAQ
    http://mywiki.wooledge.org/BashPitfalls
    http://rute.2038bug.com/index.html.gz
    http://mylinuxbook.com/linux-shell-environment/
    http://www.subsignal.org/doc/AliensB...0Of%20Contents
    http://www.rigacci.org/docs/biblio/o...TLCL-09.12.pdf
    http://www.linuxhomenetworking.com/
    http://mylinuxbook.com/bash-shell-scripting-part-i/
    http://mylinuxbook.com/bash-shell-scripting-2/
    https://help.ubuntu.com/community/CommandLineResources
    http://linuxcommand.org/lc3_learning_the_shell.php
    http://unixhelp.ed.ac.uk/
    http://www.linuxquestions.org/questi...l-links-35334/
    http://www.linuxquestions.org/questi...ks-4175433508/
    http://www.hammondslegacy.com/forum/...de3e86cafdf486
    http://linux-shell-commands.jimdo.com/
    http://flossmanuals.net/command-line
    http://tille.garrels.be/training/tldp/
    http://www.collegeathome.com/blog/20...-50-resources/
    http://www.codecoffee.com/tipsforlinux/index-linux.html
    http://www.linuxquestions.org/questi...eniuses-35795/
    http://www.google.com/cse/home?cx=01...1bdfg5ga&hl=en
    I have 3 brain cells left, and two of them have restraining orders.
    Linux is just "DOS on 'steroids"

  2. #12
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,445
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: cp and mv command - nuanced instructions

    that script is very very sloppy. Not a single variable in the whole script is protected by double-quotes against word splitting, so it will blow up on anything with whitespace in it.

    Code:
    cp $TPOTOF `echo "new-"$TPOTNF`
    o.O why not
    Code:
    cp "$TPOTOF" "new-$TPOTNF"
    ?

    backticks `` are on their way out (deprecated) and $() should be used instead.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #13
    Join Date
    Aug 2011
    Beans
    26

    Re: cp and mv command - nuanced instructions

    Hi and thanks to all for responding! Sorry I haven't replied sooner; I had a bit of a family emergency and am just now back behind the computer. Tomorrow I will try some of these solutions. I just didn't want more time to pass before saying thanks to all!

  4. #14
    Join Date
    Aug 2011
    Beans
    26

    Re: cp and mv command - nuanced instructions

    Your understanding of my question was absolutely correct. I apologize for the delayed reply; just after I wrote this I got called away due to an illness in my family. Thank you so much for your time and help!

  5. #15
    Join Date
    Aug 2011
    Beans
    26

    Re: cp and mv command - nuanced instructions

    Zeus, thank you. My hope is to accomplish something slightly different. If I have 600 files in a directory that I wish to overwrite, I don't want to manually validate all of them. Sometimes, too, the older version of a file has information or changes that I wish to keep, such as sometimes happens when collaborating on a file and someone emails it back to me with changes using the same name as the name I gave that same file -- resulting if different timestamps for different docs, each of which should be preserved.

    Imagine, for instance, that I circulate a file called text,v2.txt, then save it as text,v2-edit.txt and a colleague emails me another file called text,v2-edit.txt. We both have contributed edits, and just copying in the new file would overwrite one of our contributions. In this case, I'd like to preserve both, but to flag it as some sort of conflict or duplicate -- like text,v2-edit(2).txt (or something).

  6. #16
    Join Date
    Aug 2011
    Beans
    26

    Re: cp and mv command - nuanced instructions

    Jonathan,

    Thanks! That is a useful looking script. I'll try it. Just to be clear, however, I would also be concerned with date modified. Any ways to tweak the script accordingly?

  7. #17
    Join Date
    Feb 2008
    Location
    In my skin.
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: cp and mv command - nuanced instructions

    Quote Originally Posted by Vaphell View Post
    that script is very very sloppy. Not a single variable in the whole script is protected by double-quotes against word splitting, so it will blow up on anything with whitespace in it.

    Code:
    cp $TPOTOF `echo "new-"$TPOTNF`
    o.O why not
    Code:
    cp "$TPOTOF" "new-$TPOTNF"
    ?

    backticks `` are on their way out (deprecated) and $() should be used instead.
    Unsure if you read this.

  8. #18
    Join Date
    Aug 2011
    Beans
    26

    Re: cp and mv command - nuanced instructions

    Thank you, Bucky Ball. I did indeed read it. I will follow your suggestion and will try to clean up the script a little before implementing it. To be frank, the script is a bit daunting for me, so I'll need some time to digest it. I'm still interested in a means of accomplishing a 'create conflict' option for files based on date modified as well as date created. I simpler script would certainly be appealing. I am surprised that there isn't a more straight-forward command out there... unless there is something I am missing?

  9. #19
    Join Date
    Aug 2011
    Beans
    26

    Re: cp and mv command - nuanced instructions

    Maybe I am going about the the wrong way. Should I be working not with cp and mv, but with svn?

  10. #20
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: cp and mv command - nuanced instructions

    I'm probably going to get yelled at for this, but when I first started shell scripting, I used all caps for variables, but now I either use all lowercase or CamelCase so I don't accidentally override system variables (even if that is unlikely).
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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