Section command line

Replace a string in a large file with VI

Written by on 29/03/2021
Category:   Shell
Tags:   bash, shell, command line, linux, VI, VIM
A large file, and no powerful enough editor at hand to perform a search/replace? It's simple with vi. Edit the file with the vi command vi file Then in the editor type: :%s/mystring1/mystring2/ Remplacer une chaine dans un gros fichier avec VI Alternatively, there is another option with sed: sed -i -e "s/mystring1/mystring2/g" file If the string contains special characters, they will need to be escaped with a backslash '\' sed -i -e "s/\#mystring1/\#mystring2/g" ...

shell: mirror a directory with lftp

Written by on 28/11/2014
Category:   Linux, Shell
Migrating a large website (several gigabytes) can be a tedious task to do from your workstation (with filezilla, for example). If you have a machine at a hosting provider with shell access, the lftp solution can quickly prove to be the ultimate alternative.Retrieve the files:lftp -e 'mirror /repertoir/distant /repertoir/local' -u login,password -p 21 www.host.comSend the files:lftp -e 'mirror -R /repertoir/local /repertoir/distant' -u login,password -p 21 www.host.comSend the files with 10 si...

Ubuntu: Install RabbitVcs

Written by on 29/10/2014
Category:   Linux, Ubuntu 14.04 LTS, Shell, SVN
In fact, RabbitVcs is very easy to install... Except when there's a problem, and then... one can search for a long time 😟Here's how to resolve most installation issues on Ubuntu 14.04LTS.1 – Add the sourcesudo add-apt-repository ppa:rabbitvcs/ppa or add the source to your /etc/apt/sources.list filedeb http://ppa.launchpad.net/rabbitvcs/ppa/ubuntu trusty main2 – Install the packages sudo apt-get update sudo apt-get install rabbitvcs-cli rabbitvcs-core rabbitvcs-gedit rabbitvcs-nautilus3 3 – M...

ZEND: Create a CLI file and activate it in the shell

Written by on 15/05/2014
Category:   PHP, Shell, Zend
To add a cron job and make it accessible in the shell, you first need to configure your environment to point to the libraries.Step 1: Add the zf script to the /usr/bin/ directory (zf.sh and zf.php) These files are available in the bin directory of the ZendFramework 1.x library. You can either copy them or create a symbolic link.Step 2: Configure your bash to recognize the zf alias. Edit the ~/.bashrc file and insert the following line alias zf="/usr/bin/zf.sh" Step 3: Add the global variable ...

Shell: Delete all .svn recursively

Written by on 15/05/2014
Category:   Shell, SVN
Tags:   svn, bash, shell, command line
To recursively remove all svn management files (.svn) from a working copy, simply navigate to the root directory of your working copy and execute the following command: find . -name ".svn" -exec rm -rf {} \; Another solution is to create an alias in your ~/.bashrc and then execute the command when needed: alias rmsvn='find . -name ".svn" -exec rm -rf {} \;'

SVN: Perform a recursive add in shell

Written by on 15/05/2014
Category:   Shell, SVN
Tags:   svn, bash, shell, command line
To add files recursively from the command line with svn, we have several possibilities.The first one, probably the cleanest: svn add --force * --auto-props --parents --depth infinity -q Although only the following options seem really necessary: svn add --force * Then there are alternative solutions a bit more complicated to understand: svn status | grep '?' | sed 's/^.* /svn add /' | bash svn add `svn status .|grep "^?"|awk '{print $2}'` svn st | grep "^\?" | awk "{print \$2}" | xargs svn...