Skip to content

Instantly share code, notes, and snippets.

@cejojohn
Last active August 12, 2016 12:46
Show Gist options
  • Save cejojohn/4336ba1714f398d0fc8508a6f3e0ac3f to your computer and use it in GitHub Desktop.
Save cejojohn/4336ba1714f398d0fc8508a6f3e0ac3f to your computer and use it in GitHub Desktop.
Deleting blank spaces from files. I used it along with my scripts to configure the rsyslog server. I was provided with a jumbled list of more than hundred network switches.
#!/bin/bash
#To delete all whitespace: cat file.txt | tr -d "[:space:]"
#To delete all horizontal whitespace: cat file.txt | tr -d "[:blank:]"
#Using LibreOffice calc in the final stage I had two columns to merge. Eg:
/var/log/Switches/ Switch1
/var/log/Switches/ Switch2
. .
. .
. .
. .
. .
#So I did:
cat filename | tr -d "[:blank:]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment