I am writing a script to filter a file that has contents like
a:10
b:20
c:60
# comment
{{# random mustache templating}}
d=4
e=6
to get the output which would look like
a
b
c
d
e
Here is my command
cat filename.txt | awk '{$1=$1;print}' | awk -F'{{' '{print $1}' | awk -F'=' '{print $1}' | awk -F':' '{print $1}' | awk -F'#' '{print $1}' | awk /./
Purpose:
- Remove anything in a line from the occurrence of characters '=' or ':'.
- Remove the line that starts with '{{' to remove templating.
- Trim whitespaces at the beginning and end of each line.
- Remove all blank lines.
As I am new to bash, how can I make this command shorter?