Skip to main content

Strip bash comments with grep

Sometimes, you just want to see the code ... Let's say you want to look at a bash script, but strip out all the comments. Here's a sample command using grep that will display a bash script, without comments, to stout:
grep -v "^#" commented-script.sh
Notes:
  • "-v" means invert the selection; i.e., only display the lines in the file that don't match.
  • "^#" is the regular expression that matches "lines that start with #".
  • "^" means only match the beginning of the line.
  • Replace "commented-script.sh" with the file name of the file you want to strip.
Tips:
  • This command strips single line comments from any programming language. Just change the comment line character (";" instead of "#" for example).
  • If you just want to read the comments, drop the "-v" switch.

Comments

Popular posts from this blog

Essential Firefox Add-Ons For the Cloud

If you don't want to be tied down to a desktop, you need direct access to your computer in the cloud. Since Firefox runs just about everywhere, it's a good place to start to set up a reliable way to access your accounts. Blog & Social  Delicious Bookmarks is the recommended and official Firefox add-on for Delicious, the world's leading social bookmarking service (formerly del.icio.us). It integrates your bookmarks and tags with Firefox and keeps them in sync for easy, convenient access. Syncing slows down startup, though. ScribeFire Blog Editor is a blog editor that integrates with your browser and lets you easily post to your blog. They've also integrated their affiliate Quick Ads advertising program, which I haven't tried.

Joomla 1.5 Directory Status: Writeable

[UPDATED] Joomla 1.5 is acting flaky on one of our installations because the directories are set to ‘unwriteable’. To see the their current state, log in as Super Administrator and go to Help > System Info > Directory Permissions . Elsewhere, it's been suggested that the specified directories must be set to “world-writeable” (777). This works, but it is a very bad idea , since it means anyone can change your files! Not cool. Fixing Security with User and Group Settings To perform these changes, you need shell (command line) access to your server. If you don't have it, you can beg your host to make these changes for you, or switch to a Joomla-friendly host. I'm going to assume that you are using a LAMP (Linux/Apache/MySQL/PHP) server because if you're not, then ... well, these instructions should work in principle, but the specifics for your server may be quite different. Here's the issue: you, the FTP user, need full access to your files. So does Joomla,

Atom: Hackable Text Editor for Ubuntu

It all started when I wanted to convert some text to Title Case. Ubuntu's default text editor, gedit, is quite capable, but does not include case conversion. A quick trip to Google and I found  (gedit is number 4). Since I write some code, too, I'm always interested in a good text editor. After going through the list, I picked #2, Atom. Atom looks appealing for a number of reasons. It's available through the Ubuntu Software app (almost -- see below for details) It's built on web technologies. It's cross-platform. From the article: Atom is a free and open source text editor that’s developed by GitHub. Based on Electron (CoffeeScript, JS, Less, HTML), it’s a desktop application that’s built using web technologies ... The major features of Atom are cross-platform editing, built-in package manager, file system browser, multiple pane support, find and replace function, and smart autocompletion. You can select from 1000s of open source packages and add