User Controls

I need to step up my Bash game.

  1. #1
    Sophie Pedophile Tech Support
    Bleh thought i was doing a good job suppose not. Any help would be appreciated.


    #!/bin/bash

    dir="/home/backup/tmp"

    echo "Move files?"
    read -p 'Y/n? : ' choice

    if [ "$choice" == "Y" ]
    then

    mkdir -p /home/backup/tmp

    sudo find / -name cp.* >> /tmp/bla.txt
    list="/tmp/bla.txt"

    cat $list | xargs -I % bash -c 'mv % -t /home/backup/tmp' && rm -f $list;

    cd $dir

    for i in $dir

    do `clzip --fast`
    done

    exit 1
    else
    echo "Exiting..."
    exit 0
    fi









    Move files?
    Y/n? : Y
    mkdir: cannot create directory ‘/home/backup/tmp’: No such file or directory
    find: paths must precede expression: cp.rar
    Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
    ./noice.sh: line 10: =/tmp/bla.txt: No such file or directory
  2. #2
    Merlin Houston
    Does /home/backup exist? If not use mkdir -p
  3. #3
    Sophie Pedophile Tech Support
    Does /home/backup exist? If not use mkdir -p

    Thanks for the reply i may also tweak the "find" operation a little.
  4. #4
    Merlin Houston

    See the comments "# !!", I don't have clzip, but I assume that portion will work. You fucked up a bunch of basics, but good on the find and xargs stuff I never keep that straight.

    #!/bin/bash
    # !! nigga it's hash bang not bang hash

    # !! don't use $ when assigning
    dir="/home/backup/tmp"

    echo "Move files?"
    read -p 'Y/n? : ' choice

    if [ "$choice" == "Y" ]
    then

    # !! make parent dirs too
    mkdir -p /home/backup/tmp

    # !! remove backtick (don't know if this matters) and quote the find string (you sick fuck)
    sudo find / -name 'cp.*' >> /tmp/bla.txt
    # !! don't use $ when assigning and use quotes
    list='/tmp/bla.txt'

    # you already mv'ed everything in list, just rm $list
    cat $list | xargs -I % bash -c 'mv % -t /home/backup/tmp' && rm -f $list;

    cd $dir

    for i in $dir

    do `clzip --fast`
    done

    exit 1
    else
    echo "Exiting..."
    exit 0
    fi
  5. #5
    Merlin Houston
    Also Lanny plz halp, I can't make a new thread:

    That action could not be completed. Please try again, and if this occurs again please contact the system administrator and tell them how you got this message.

  6. #6
    Sophie Pedophile Tech Support
    Also Lanny plz halp, I can't make a new thread:

    That action could not be completed. Please try again, and if this occurs again please contact the system administrator and tell them how you got this message.

    Sorry the shebang line was a typo. Also good point about the dollar sign, I know some bash, but it's been ages since i wrote a shellscript. I'm much better with python TBH.
  7. #7
    Merlin Houston
    Sorry the shebang line was a typo. Also good point about the dollar sign, I know some bash, but it's been ages since i wrote a shellscript. I'm much better with python TBH.

    Yeah bash syntax always feels off. It's a good brain exercise to switch around I guess.
Jump to Top