Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Monday, February 6, 2017

How to Recursively Delete Files from a Folder


Let say you want to delete all files of type ".bak" recursively from a folder.

Step 1: List all the files of ".bak" in the folder to check whether you will delete the correct files.
  1. Open up Terminal
  2. In the command line, type:
    cd
  3. Drag and drop the folder you wish to delete ".bak" files from.
  4. Press enter.
  5. In the command line, type:
    find . -name '*.bak' -type f
  6. Press enter.

If you are confirmed that you want to delete the listed files, proceed to Step 2.

Step 2: Delete all the "*.bak" files.
  1. In the command line, type:
    find . -name '*.bak' -type f -delete
  2. Press enter.

Please be careful.

Wednesday, April 22, 2015

wget: Download files with certain extension only

To download only files of type pdf from example.com,
wget -r --no-parent --accept "*.pdf" --level 2 http://example.com/

Thursday, November 19, 2009

3 free online resources to help you learn Linux commands

These websites should provide you with the basic (up to advance) command line skills, as well as teach you some neat command line tricks.

1. LinuxCommand.org




LinuxCommand.org is a Linux education and advocacy site devoted to helping users of Linux operating systems.

Visit LinuxCommand.org.

2. Linux Command Directory



Linux Command Directory is a directory of 687 Linux commands with descriptions.

Visit Linux Command Directory.

3. The Linux Cookbook



The Linux Cookbook presents "recipes" for preparing or accomplishing a particular, specific thing.

Visit The Linux Cookbook.

Monday, October 26, 2009

Change file format (Dos/Unix) in Vim

Unix and dos (Windows) use different file format. Even though the latest Vim can detect the file format automatically, sometimes you also need to convert your file to the other format, especially if you are sharing the file with your friends.

Fortunately, in vim you can set the file format using a very simple command.

Change the file format to dos

:set ff=dos

Change the file format to unix

:set ff=unix

Note:

You can also add those commands in .vimrc file to make Vim starts with the desired format of file.

Friday, March 20, 2009

Quick list of unix shell commands

Some Unix or Linux shell commands.

Cancel a command

Ctrl+U, Ctrl+X, or @

Change the working directory to /usr

cd /usr

Change the working directory back to your home directory

cd

Copy a file

cp oldfile newfile

Copy a file to another directory

cp oldfile dirname

Copy a bunch of files (e.g. filename1, filename2, ...) to another directory

cp filename* dirname

Copy all the files in this directory and in all its subdirectories

cp -r * newdir

Erase a file

rm filename

Rename a file

mv oldname newname

Move a file to another directory

mv oldfile dirname

List filenames

ls

List filenames with sizes and dates

ls -l

List hidden files too

ls -al

List files and pause when screen is full

ls | more

Look at a text file

cat filename

Look at a long text file

more filename

Make a new link (name) for a file

ln oldname newname

Make new links (names) for files in a directory

ln dirname/* newdir

Combine two files

cat file1 file2 > newfile

Compare two files

diff file1 file2

Look at the manual page for the ls command

man ls

Change your password

passwd