|
|
| | | |
| | | |
| n | | n | Get a coma separated list of libvirt guests |
| | | ================================================== |
| | | |
| | | .. code-block:: bash |
| | | |
| | | virsh list | egrep -v 'Domain|Name|----|^$' | awk '{printf "%s," , $2}' > /tmp/ |
| | | virthosts |
| | | |
| | | |
| | | |
| t | | t | |
| | | |
|
|
| .. code-block:: sed | | .. code-block:: sed |
| | | |
| t | sed -i'' -e 's/\:80/\:8080/g' * | t | sed -i'' -e 's/search/replace/g' * |
| | | |
| | | |
|
|
| | | |
| | | |
| t | | t | Bash sed search and replace multiple files one liner |
| | | ============================================================ |
| | | |
| | | .. code-block:: sed |
| | | |
| | | sed -i'' -e 's/\:80/\:8080/g' * |
| | | |
| | | |
| | | |
| | | |
| | | |
|
|
| | | |
| | | |
| t | | t | Bash Perl search and replace multiple files one liner |
| | | ======================================================= |
| | | |
| | | .. code-block:: perl |
| | | |
| | | perl -pi -w -e 's/search/replace/g;' *.extension |
| | | |
| | | explanation: |
| | | |
| | | **-e** |
| | | means execute the following line of code. |
| | | |
| | | **-i** |
| | | means edit in-place |
| | | |
| | | **-w** |
| | | write warnings |
| | | |
| | | **-p** |
| | | loop |
| | | |
| | | |
| | | |
|
|
| done | | done |
| | | |
| t | apache logs count unique | t | apache logs count unique ip addresses |
| ============================= | | ========================================= |
| | | |
| .. code-block:: bash | | .. code-block:: bash |
|
|
| done | | done |
| | | |
| t | | t | apache logs count unique |
| | | ============================= |
| | | |
| | | .. code-block:: bash |
| | | |
| | | sudo cat access.log | awk '{ print $1; }' | sort | uniq -c | sort -n |
| | | |
| | | |
| | | |
|
|
| | | |
| sudo find . -type d -print0 | xargs -0 sudo chmod 0775 | | sudo find . -type d -print0 | xargs -0 sudo chmod 0775 |
| t | | t | |
| | | Remove a particular line from all files in a directory |
| | | ============================================================ |
| | | |
| | | .. code-block:: bash |
| | | |
| | | for file in /tmp/test/* |
| | | do |
| | | cp -p $file $file.tmp |
| | | egrep -v "RegexToRemove" $file.tmp > $file |
| | | rm -rf $file.tmp |
| | | done |
| | | |
|
|
| t | | t | advanced bash techniques |
| | | ============================ |
| | | |
| | | find and change all files: |
| | | |
| | | sudo find . -type f -print0 | xargs -0 ls -hal |
| | | |
| | | sudo find . -type f -print0 | xargs -0 sudo chown www-data:www-data |
| | | |
| | | sudo find . -type f -print0 | xargs -0 sudo chmod 0644 |
| | | |
| | | find and change all directories: |
| | | |
| | | sudo find . -type d -print0 | xargs -0 sudo chmod 0775 |