How to show a script without comments?
Ralf Mardorf
silver.bullet at zoho.com
Mon Aug 1 10:25:47 UTC 2016
Hi,
how can I display a shell script without comments and empty lines, but
also without cutting commands?
This is an example text file:
[weremouse at moonstudio tmp]$ cat test.txt
## test file.
test # test
test 2
echo "Hello #"
echo "Hello #" # Oops
A simple egrep line, doesn't remove all comments:
[weremouse at moonstudio tmp]$ egrep -v "^#|^$" test.txt
test # test
test 2
echo "Hello #"
echo "Hello #" # Oops
A simple sed line, does remove all comments, but cuts commands:
[weremouse at moonstudio tmp]$ sed "s/#.*$//g" test.txt | grep -v ^$
test
test 2
echo "Hello
echo "Hello
Regards,
Ralf
More information about the ubuntu-users
mailing list