Sunday, 20 February 2011

[: missing `]' +bash +shell scripts

 "=" sign requires a blank in front of it and after it. Otherwise, the bash only sees "something" within the brackets, and that is true (0), while "nothing" is false (1):

ex.
[ 5 = 6]
 
solution 
[ 5 = 6 ] 
 
 
Tutorials:
http://wiki.linuxquestions.org/wiki/Bash_tips
http://www.tldp.org/LDP/abs/html/
https://wiki.archlinux.org/index.php/Color_Bash_Prompt 

Tuesday, 8 February 2011

Solution: merge two files / append two files in Linux

Code:
cat file1 file2 .. fileN  > mergedfile
Note the '>' in the command: it points that the target file follows, don't forget to put it there.

Advance:
 
If you accept that entries in the resulting file are sorted, you can use uniq to remove duplicates.

Code:
cat file1 file2 | sort | uniq > mergedfile

Wednesday, 2 February 2011

Solution : raise TypeError("bufsize must be an integer")

Error : subprocess.call(['vim'],['/home/patelm/.bashrc'])

Solution: subprocess.call(['vim','/home/patelm/.bashrc'])


Whenever you're running subprocess.call and you see this
error, say to yourself: "Have I passed the command line
as one parameter in a list; or have I passed it as a series
of parameters?"

diff rcs file

Code:
rcsdiff -r1.1 -r1.2 -u file

here we are diffing rev 1.2 agains 1.1


If you want to colour the output you can use the idiff script


Code:
rcsdiff -r1.1 -r1.2 -u file | ./idiff