Wednesday, April 4, 2007

Where I start

The following unix/lunix commands are what I ususally use.

# List the files under current directory with specified string1?
find / -name "*.jsp" -exec grep "web" {}\;
# List the files in current directory sorted by size ?
ls -l | grep ^- | sort -nr
# List the hidden files in current directory ?
ls -a1 | grep "^\."
# Delete blank lines in a file ?
cat sample.txt | grep -v '^$' > new_sample.txt
# Search for a sample string in particular files ?
grep "anything" *.conf
# Display the all files recursively with path under current directory ?
find . -depth -print
.Display the files in the directory by file size ?
ls -lrt | sort -nr -k 5
# How much space is used for users in kilobytes ?
quot -af
# How to create null file ?
cat /dev/null > filename1
# How to save man pages to a file ?
man | col -b >
# How do you find out drive statistics ?
iostat -E
# Display disk usage in Kilobytes ?
du -k
# Display top ten largest files/directories ?
du -sk * | sort -nr | head
# Display the Disk Usage of file sizes under each directory in currentDirectory ?
du -k * | sort -nr
du -k . | sort -nr
# Display the page size of memory ?
pagesize -a
# Display Ethernet Address arp table ?
arp -a
# Display the no.of active established connections to localhost ?
netstat -a | grep EST
# Display the state of interfaces used for TCP/IP traffice ?
netstat -i
# Alternative for top command ?
prstat -a
# Do a search and replace on a given string in all of the files in the current directory
perl -p -i -e 's/oldstring/newstring/g' *
# Do a search and replace on a given string in all of the files recursively across the current directory
perl -p -i -e 's/oldstring/newstring/g' `find ./ -name *.html`
# Delete a file by inode
find . -inum 596409 -exec rm -i {} \;
# Save line 201 to line 400 of a file to another file
vi file1
:201,400 w!file2
# Sort line 101 to line 100 of a file
vi file2
:101,200 !sort

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home