| by Scott Kilroy

Find the largest file in a directory tree

find /path -type f -exec ls -s {} \; | sort -n | tail -1

Share Button
Read More
| by Scott Kilroy

Compress the contents current directory, but compress the smallest files first

ls -s | awk NR!=1 | sort -n | awk ‘{print $2}’ | xargs bzip2 -9v

Share Button
Read More
| by Scott Kilroy

Using netstat

netstat -ntulp displays everything that is listening tcp and udp and the ip that it is listening on

Share Button
Read More
| by Scott Kilroy

View network traffic (by port number)

To view web traffic (for example) use tcpdump -s 0 -w – port 80 | tcpdump -r – -A

Share Button
Read More
| by Scott Kilroy

VIM guide

A good basic starting point for using Vim is http://www.pixelbeat.org/vim.tips.html

Share Button
Read More
| by Scott Kilroy

Filter duplicate lines from a sorted files

cat list-1 list-2 list-3 | sort | uniq > final.list

Share Button
Read More
| by Scott Kilroy

Debugging bash scripts

Debugg bash scripts by runing with option -x example bash -x scriptname.sh

Share Button
Read More
| by Scott Kilroy

lowercase filen names

#! /bin/bash DIR=$1 for a in `ls $DIR` do fname=`echo $a | tr A-Z a-z` mv $DIR/$a $DIR/$fname done; exit 0

Share Button
Read More