Skip to content

Instantly share code, notes, and snippets.

@phunehehe
Last active December 14, 2015 19:08

Revisions

  1. phunehehe revised this gist Dec 6, 2013. 1 changed file with 0 additions and 18 deletions.
    18 changes: 0 additions & 18 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,3 @@
    Enable `autostart` for running VMs

    ```bash
    for i in $(virsh list | grep running | awk '{print $2}')
    do
    virsh autostart $i
    done
    ```

    Disable `autostart` for shut-off VMs

    ```bash
    for i in $(virsh list --all | grep 'shut off' | awk '{print $2}')
    do
    virsh autostart --disable $i
    done
    ```

    Print permissions in a way that is suitable for executing again

    ```bash
  2. phunehehe revised this gist Mar 11, 2013. 1 changed file with 19 additions and 13 deletions.
    32 changes: 19 additions & 13 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,30 @@
    Enable `autostart` for running VMs

    for i in $(virsh list | grep running | awk '{print $2}')
    do
    virsh autostart $i
    done
    ```bash
    for i in $(virsh list | grep running | awk '{print $2}')
    do
    virsh autostart $i
    done
    ```

    Disable `autostart` for shut-off VMs

    for i in $(virsh list --all | grep 'shut off' | awk '{print $2}')
    do
    virsh autostart --disable $i
    done
    ```bash
    for i in $(virsh list --all | grep 'shut off' | awk '{print $2}')
    do
    virsh autostart --disable $i
    done
    ```

    Print permissions in a way that is suitable for executing again

    for i in *
    do
    echo chown $(stat -c%U:%G $i) $i
    echo chmod $(stat -c%a $i) $i
    done
    ```bash
    for i in *
    do
    echo chown $(stat -c%U:%G $i) $i
    echo chmod $(stat -c%a $i) $i
    done
    ```

    Rename files to remove special characters

  3. phunehehe revised this gist Mar 11, 2013. 1 changed file with 16 additions and 16 deletions.
    32 changes: 16 additions & 16 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -22,19 +22,19 @@ Print permissions in a way that is suitable for executing again

    Rename files to remove special characters

    ~~~zsh
    #!/bin/zsh
    for f in "$1"/**/*
    do
    if [ -f "$f" ]
    then
    dir_name=$(dirname "$f")
    file_name=$(basename "$f")
    name=${file_name%.*}
    ext=${file_name:(-4)}
    good_name=$(echo "$name" | sed -re 's/\W+/_/g' -e 's/_+/_/g')"$ext"
    [[ "$file_name" == "$good_name" ]] || echo mv "$f" "$dir_name"/"$good_name"
    fi
    done
    ~~~
    ```bash
    #!/bin/zsh

    for f in "$1"/**/*
    do
    if [ -f "$f" ]
    then
    dir_name=$(dirname "$f")
    file_name=$(basename "$f")
    name=${file_name%.*}
    ext=${file_name:(-4)}
    good_name=$(echo "$name" | sed -re 's/\W+/_/g' -e 's/_+/_/g')"$ext"
    [[ "$file_name" == "$good_name" ]] || echo mv "$f" "$dir_name"/"$good_name"
    fi
    done
    ```
  4. phunehehe revised this gist Mar 11, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ Print permissions in a way that is suitable for executing again

    Rename files to remove special characters

    ~~~zsh
    ~~~zsh
    #!/bin/zsh

    for f in "$1"/**/*
    @@ -37,4 +37,4 @@ Rename files to remove special characters
    [[ "$file_name" == "$good_name" ]] || echo mv "$f" "$dir_name"/"$good_name"
    fi
    done
    ~~~
    ~~~
  5. phunehehe revised this gist Mar 11, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion commands.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,7 @@ Print permissions in a way that is suitable for executing again

    Rename files to remove special characters

    ~~~zsh
    #!/bin/zsh
    for f in "$1"/**/*
    @@ -35,4 +36,5 @@ Rename files to remove special characters
    good_name=$(echo "$name" | sed -re 's/\W+/_/g' -e 's/_+/_/g')"$ext"
    [[ "$file_name" == "$good_name" ]] || echo mv "$f" "$dir_name"/"$good_name"
    fi
    done
    done
    ~~~
  6. phunehehe revised this gist Mar 11, 2013. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -18,4 +18,21 @@ Print permissions in a way that is suitable for executing again
    do
    echo chown $(stat -c%U:%G $i) $i
    echo chmod $(stat -c%a $i) $i
    done

    Rename files to remove special characters

    #!/bin/zsh
    for f in "$1"/**/*
    do
    if [ -f "$f" ]
    then
    dir_name=$(dirname "$f")
    file_name=$(basename "$f")
    name=${file_name%.*}
    ext=${file_name:(-4)}
    good_name=$(echo "$name" | sed -re 's/\W+/_/g' -e 's/_+/_/g')"$ext"
    [[ "$file_name" == "$good_name" ]] || echo mv "$f" "$dir_name"/"$good_name"
    fi
    done
  7. phunehehe revised this gist Mar 11, 2013. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,12 @@ Disable `autostart` for shut-off VMs
    for i in $(virsh list --all | grep 'shut off' | awk '{print $2}')
    do
    virsh autostart --disable $i
    done

    Print permissions in a way that is suitable for executing again

    for i in *
    do
    echo chown $(stat -c%U:%G $i) $i
    echo chmod $(stat -c%a $i) $i
    done
  8. phunehehe revised this gist Mar 11, 2013. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,11 @@ Enable `autostart` for running VMs
    for i in $(virsh list | grep running | awk '{print $2}')
    do
    virsh autostart $i
    done

    Disable `autostart` for shut-off VMs

    for i in $(virsh list --all | grep 'shut off' | awk '{print $2}')
    do
    virsh autostart --disable $i
    done
  9. phunehehe created this gist Mar 11, 2013.
    6 changes: 6 additions & 0 deletions commands.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    Enable `autostart` for running VMs

    for i in $(virsh list | grep running | awk '{print $2}')
    do
    virsh autostart $i
    done