Find the answer to your Linux question:
Results 1 to 2 of 2
I am trying to complete a script that reads a text file and only includes lines that do not start with a "#" symbol. How would you go about it? ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    1

    How do I test for the presents of a character in a string?


    I am trying to complete a script that reads a text file and only includes lines that do not start with a "#" symbol. How would you go about it?

    Thanks in advance

  2. #2
    Linux User cheesecake42's Avatar
    Join Date
    Jan 2007
    Location
    Orlando, FL
    Posts
    370
    use grep with the -v option and escape the #. For example, if you are catting "test.txt"

    Code:
    cat test.txt | grep -v \#
    this will display all lines within test.txt excluding any that contain a "#".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •