VI :: remove break lines with search/replace

source: tech-recipes
To remove the carriage-return character from a windows originating file in vi:



In UNIX, you can escape a control character by preceeding it with a CONTROL-V. The :%s is a basic search and replace command in vi. It tells vi to replace the regular expression between the first and second slashes (^M) with the text between the second and third slashes (nothing in this case). The g at the end directs vi to search and replace globally (all occurrences).

Find and count files

Find and count files categorized per file extension:

find . \( -name . -o -prune \) -type f | sed -n 's/..*\.//p' | sort -f | uniq -c

find and do things

Find and delete files older than today in current directory

find . -mtime +0 -exec rm -f {} \;


find /any/directory/you/may/have/ -type f -mtime +15 -exec rm -f {} +

find and do things

T-bit and S-bit on *nix

Just came across a directory with these permissions: drwxr-sr-x

Here’s howto set it:

chmod 2755 

Here are the sources: example man

Find and do things in *nix

Find stuff in *nix:

find /file_system/file_system -name file_name -type f -exec rm {} ;
What this does is, find files (-type f) with the name file_name in given file_system and executes rm

Kill a nohup process

Of course you can use kill -9 pid, but sometimes you just can’t find the pid.
In that case try: fg.

Counting lines on *nix

To count number of process occurrences on *nix:

ps -ef|grep search_attribute|wc -l


Create TAR file:
tar -cvf archive_file.tar file_to_archice.doc

Append a file to a TAR file:
tar -uvf archive_file.tar file_to_archice.doc

Extract a TAR file:
tar -xvf archive_file.tar directory_to_extract

List the contents of a TAR file:
tar -tvf archive_file.tar

Read the rest of this entry »

Remove an entire directory in *nix

Even when it’s used:

rm -rf /file_system/file_system/fil…..

Mailing from unix

If you regard mailing from unix as quite a hassel, see the following:
uuencode old_file_name new_file_name | mailx -r reply_address -s “subject” to_address

In this manner, the file that you send with mailx, will be attached via uuencode.
If you need to send more files, tar hem.