Subscribe: in Google Reader, by email, Twitter, or other options.
-->

HG’s Five Text Processing Tools for Linux

Any Linux Distro has many text processing tools installed by default. We can use these tools to get some of the desired outputs. Although every precautions have been taken in writing this post , still if you find some error please notify us [ WE are HUMAN and to ERR is Human ;-) ]

So here starts a short guide on various text processing tools.

1) tail
Short Description : output the 10 last lines of files

usage

$tail /your/path/to/file

the above command will display last 10 lines of the desired file. With the following arguments [ or in technical term switch ] you can get more out of it

$tail -n 2 /file/address

The above will display last 2 lines of your desired file [ you can change the value 2 with your own variable ;-) ]

$tail -f /file/address

This command is very useful to watch log files of ur Linux Box. This switch append the output with the changes in the file
$tail -v /file/name
This command will print the absolute file address of the file and then will output the last part of that file

2) head
Short Description : output the first 10 lines of files

usage
$head /your/path/to/file

The above command will display first 10 lines of the desired file. The “ head” command can be further customized with following switches

$head -n 4 /file/name
The above will print First four lines of your desired file [ please change value from 4 to your desired number / variable ]

$head -v /file/name
It will print file name and then will produce the head output :D

3) grep
Short Description : print lines matching a pattern

grep is really nice utility for searching a text withing a long file . It prints that line where the text is found

usage
$grep search_string /file/address
The above command will search for search_string in /file/address named file [ replace the search_string with what you want to search and /file/address with your file address]

4) sed
Short Description : stream editor for filtering and transforming text.

Usage
$sed -e 's:search:replace:g' /file/name

The above will produce output by replacing search string [ it will not change file ]

Now the main tool that is spell checking tool

5) aspell
Short Description: spell checking utility

usage
$aspell check /file/name
will check /file/name for any error and prompt if spelling error found. User then can replace correct spelling and it will be saved in file

$aspell list < /file_name
This will list of misspelled word from /file_name

So this was some shortlisted and commonly used text processing tools . Please note that this was basic text editing strings which are/may_be commonly used . For further info refer to each utilities manual entry ;-)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • StumbleUpon
  • TwitThis
  • E-mail this story to a friend!
-->

No comments yet

Leave a Reply





Psst.. we have kicked

spam butt. So think again before submitting your comment ;-)