Pages

Wednesday, March 28, 2012

Arithmetic equations in bash

Basic equations in bash scripts:

x=15
y=8
sum=$((x+y))

dif=$((x-y))

mod=$((x%y))

prod=$((x*y))

Tuesday, March 6, 2012

How to search a word in multiple files

1. Search a word in all the files with the .txt extension in current directory.

 grep -H "word" *.txt

2. Search a word in all the files in current directory and its subdirectories. 

grep -H -r "word" home/directory

-H = display the name of the file
-r = search recursively trough subdirectories