Sunday, February 19, 2012

Linux Reference Page

##Finding particular text in files
Find all the *.java files which contains the string confirmStatus in directory src (relative to the current directory).

command$  find ./src -name \*.java | xargs grep -il 'confirmStatus'
find commands searches list of files and passes the list to xargs, which in turns split the list and passes the each file name as argument to grep command.

##Change Domain password from Linux
smbpasswd -r -U

## Setting up Printer in Ubuntu Linux
$ gksudo system-config-printer

## Mounting Share drive in Guest Ubuntu Oracle Virtual Box
To mount a shared folder say C:\MyVideos as MySharedVideos
sudo mount -t vboxsf MySharedVideos  /media/siddshare2

where MySharedVideos is the shared folder name and /media/siddshare2 is the mount point location.

## Printing all contents to a single line
Where myfile.txt contains some text data which we want to print in a single line.
cat myfile.txt | tr -d '\n' > oneline.txt

## Changing multiple files content
perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt

No comments :

Post a Comment