Category: bash
-
Drush bash commands
Drush is a command line to manage Drupal. These are some usage example. # create a list of enabled modules drush sm –pipe –status=enabled # create txt file which contains a list of enabled modules drush sm –pipe –status=enabled | cat > modules_enabled.txt # — SVN —- # Remove all .svn folders in a directory…
-
What is the shell you are currently in ?
Simple command to find out what shell you are using. ps -ef | grep $$ | awk ‘{print $8}’
-
Find: UNIX regexp search down a directory tree
How to make a regexp search with find recursively . If you want to search only in php files, replace file_pattern with “*.php” find . -iname -exec grep -n {} \; -print
-
Simple way to get stats from Apache
This way you can get stats from your logs but this method is a little bit rudimentary as you are going to get visits from crawlers, bots,… that are not real visits. Parse your logs directly with awk. #!/bin/sh echo ‘Number of unique visitors’ cat /var/log/apache/www.yoursite.com-access.log |awk ‘{print $1}’ | sort | uniq | wc…
-
List Files in RPM Installed Package
If you want to know what files a rpm package copied to your system, you can find it out executing the following command: rpm -ql foo
-
Find and delete
Find files and directories containning your search terms, and delete them witout confirmation and recursively. No matter if they are not empty. find . -name “search_terms” -exec rm -rf {} \;
-
Getting size of a directory using du
Get the size of the current directory (.) or another one (foldername) with du command. du -sh . du -sh foldername
-
Snippet to remove caps and spaces from filename
Remove caps and spaces from names in files in current directory with tr command. First step is parse the name of the file or directory and then rename it. for f in *; do file=$(echo $f | tr A-Z a-z | tr ‘ ‘ _) [ ! -f $file ] && mv “$f” $file done
-
Download a Web Site with wget
Wget is a tool to download websites from cli. How to download an entire site could be acomplished with the following example: wget \ –recursive \ –no-clobber \ –page-requisites \ –html-extension \ –convert-links \ –restrict-file-names=windows \ –domains demosite.org \ –no-parent \ www.demosite.org/html/