Skip to content

Instantly share code, notes, and snippets.

@phx
Created June 19, 2013 06:12
Show Gist options
  • Save phx/5812027 to your computer and use it in GitHub Desktop.
Save phx/5812027 to your computer and use it in GitHub Desktop.
remove extra whitespaces
#!/bin/bash
# removes all "extra" whitespace (leaves normal spaces)
cat "web.txt" | awk '{$1=$1}1'
# removes only leading and trailing whitespace
cat "web.txt" | awk '{gsub(/^ +| +$/,"")}1'
# this perl command should do the same thing
cat "web.txt" | perl -lape 's/^\s+|\s+$//g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment