Category Archives: Linux Command Line

Linux – Autocompletition With Commands in The History

+R If you want this functionality bound to the vertical arrows, add this to your ~/.inputrc: # non-incremental search of history based on the text between the prompt and the cursor # up arrow “\e[B”: history-search-forward # down arrow “\e[A”: … Continue reading

Posted in Linux Command Line | Leave a comment

Linux – List Files Sorted By Date

ls -latr t -> sort by time r -> reverse order with any type sorting

Posted in Linux Command Line | Leave a comment

Sftp

sftp -oPort=port_number username@host

Posted in Linux Command Line, Web Development | Tagged | Leave a comment

Linux – Getting Back a Deleted File

You can get back deleted files if they are still loaded by any application. For example, let’s say I’ve deleted the file myfile by mistake but I have got it still open with vim. What I can do in order … Continue reading

Posted in Linux Command Line, PHP, Web Dev Security | Leave a comment

Linux – Search and Replace – Recursive and Over Multiple Files

find dir_name -exec perl -pi -w -e ‘s/search_reg_exp/replace_reg_exp/g;’ {} \; Be careful: search_reg_exp and replace_reg_exp are regular expressions then you may need to escape some special characters.

Posted in Linux Command Line, Web Development | Leave a comment

Automatic Batch Sftp With Expect

Expect is a tool for automating interactive applications such as telnet, ftp, passwd, fsck, rlogin, tip, etc. Expect FTP This code helps use to understand how to use command line arguments and string concatenation with Expect and with any Tlc … Continue reading

Posted in Linux Command Line, Web Development | Tagged , | Leave a comment

Linux | Recursive FTP download with wget

w*g*e*t -r ftp://username:password@host/relative_path_from_username_homedir You need to remove the asterisks (I used that just to work around a security measure by wordpress, I guess). The directory will be download in a local directory: host/relative_path_from_username_homedir retaining the remote filesystem structure Alternatively you … Continue reading

Posted in Linux Command Line | Tagged | Leave a comment

Linux : Recursive grep on only php files

This finds recursively and prints the name of all those php files containing the pattern my_pattern grep -ri “my_pattern” /path/to/directory/*.php This finds recursively and prints the name of all those php files containing the pattern my_pattern find . -name *.php … Continue reading

Posted in Linux Command Line | Leave a comment

Imagemagick: Batch Resize Photos Recursively

apt-get install imagemagick I’ll resize recursively all the photos with .jpg extension in a square frame 700×700 retaining the ratio: find ./ -name “*.jpg” -exec mogrify -resize 700×700 {} \;

Posted in Linux Command Line | Leave a comment

Command Line: Print

/usr/bin/lpr -P Officeprinter -o InputSlot=Default -o PageSize=A4 -o Duplex=None

Posted in Linux Command Line | Leave a comment