Bash 什么在听什么端口/插座?

netstat -an

Bash 带有SVN的新Rails项目的Bash脚本

#!/bin/bash

echo "########################################"
echo "This bash script creates a new rails project and do the initial svn import with ignoring/deleting files from subversion"
echo "Please send your feedback to Akhil Bansal<bansalakhil30.10@gmail.com>"
echo "I have tested this script and it works great on my system."
echo ""
echo ""
echo "                    ###### ATTENTION #######"
echo ""
echo ""
echo "Use this script at your own risk, if your computer explodes its not my fault :-) "
echo "#######################################"

echo "Enter svn username: "
read username
echo "Enter the svn url: "
read svn_url

echo "Enter Rails Application Path:(eg: /home/akhil/ror): "
read app_path
echo "Enter Application Name: "
read app_name

echo "######################################"
echo "Please verify the following variables: "
echo "Svn Username: ${username}"
echo "Svn URL: ${svn_url}"
echo "Application Path: ${app_path}"
echo "Application name: ${app_name}"

echo "Proceed (y/n)"
read proceed

if [ ${proceed} = n ] || [ ${proceed} = N ]
    then
    echo "Tenminating..."
    exit 0
elif [ ${proceed} = y ] || [ ${proceed} = Y ]
    then
    app_root="${app_path}/${app_name}"
    echo "Generating rails project: (${app_root})"
    rails ${app_root}

    echo "SVNinitial import: "
    svn import ${app_root} ${svn_url} -m "Initial Import" --username $username


   
    rm -rf ${app_root}
   
    echo "Checking out from svn: "

    svn checkout ${svn_url} ${app_root}
    cd ${app_root}
    echo "Removing all log files from SVN"
    svn remove log/*
    echo "commiting..."
    svn commit -m 'removing all log files from subversion'
    echo "Ignoring all log files under log dir"
    svn propset svn:ignore "*.log" log/
    echo "Updating and commiting..."
    svn update log/
    svn commit -m 'Ignoring all files in /log/ ending in .log'
    echo "Removing tmp directory from SVN"
    svn remove tmp/
    echo "commiting..."
    svn commit -m 'removing the temp directory from subversion'
    echo "Ignoring tmp dir"
    svn propset svn:ignore "*" tmp/
    echo "Updating and commiting again...."

    svn update tmp/
    svn commit -m 'Ignore the whole tmp/ directory, might not work on subdirectories?'
    echo "Moving database.yml to database.example"
    svn move config/database.yml config/database.example
    echo "commiting..."
    svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'
    echo "Ignoring database.yml , updating and commiting..."
    svn propset svn:ignore "database.yml" config/
    svn update config/
    svn commit -m 'Ignoring database.yml'

else
    echo "Unknown Input. Exiting..."
	exit 0
fi

Bash 解压到另一个目录

$ pax -w -s,/full/path/A,/full/path/B, -f /tmp/files.tar /full/path/A
$ tar -tf /tmp/files.tar
  /full/path/B
  /full/path/B/lib
  /full/path/B/lib/bar.txt
  /full/path/B/foo.txt

Bash 带有调试选项的ssh

#substitute user for your username and 0.0.0.0 for the ip of the server
sh -v -v -v user@0.0.0.0

Bash 导入subversion工作副本中的所有新文件

svn status|grep '?' |cut -b 8-|xargs svn add

Bash Rechercher du texte dans desfichierszippé

zcat ./*.gz | grep "6501469"
recursif :  zcat -r . | grep "898723"

Bash 处理

- Afficher la liste des process : 
ps
ps awx
- Arreter un process
kill PID (obtenu par ps)

Bash Créerunlien virtuel

ln -s target link_name

Bash Recherche d'un fichier

find . -name "*dedicace*" -print
locate nomfichier

Bash deziper un fichier gz

gzip -d stock_front.txt.gz
unzip