perl -p -e 's/^\s+//' < file1 > file2 #### while(<>) { # whatever is in -e print $_; }