add

Tuesday, November 27, 2012

Compare two files using linux comm command

Comm Command: (to use this command file must b first sorted like cat file|sort > file1)
for Common : comm -1 -2 file1 file2
Ignore
-1 Ignore File1
-2 Ignore File1
-3 Ignore common data
Example:
File1
1
2
3
4
5

File2
3
4
5
6
7


comm -1 -2 file1 file2 => 3,4,5


comm -1 -3 file1 file2 => 6,7

Friday, November 2, 2012

pregmatch for shell script


*     matches any string of zero or more characters
?     matches any single character
[ ]   matches any single character within the set
[! ]  matches any single character not in the set


These can be combined together to form more advanced patterns:
[Yy]* Matches any string starting with an upper or lower case y.

Use quotes or escape/back-slash the special characters if you wish to pattern match them specifically.