0

I'd like to populate a shell variable with the file contents of the file that follow the # (but leave the file as-is) from beginning of one single-line file

I tried

file=$(head -n1 $another_filename | sed 's/^#//')

but output is the same. I don't want to delete the whole line, just hash.

pole gar
  • 53
  • 9
  • 2
    `sed -i.bak 's/^#//' file` – P.... Oct 03 '16 at 08:34
  • 1
    Possible duplicate of [Delete all lines beginning with a # from a file](http://stackoverflow.com/questions/8206280/delete-all-lines-beginning-with-a-from-a-file) – Inian Oct 03 '16 at 08:45
  • 1
    Another demonstration of [useless use of cat](http://porkmail.org/era/unix/award.html#cat) – Inian Oct 03 '16 at 08:48
  • Are you REALLY trying to remove the `#` from the file or are you trying to populate a shell variable with the file contents of the file that follow the `#` but leave the file as-is? [edit] your question to include concise, testable sample input and expected output. – Ed Morton Oct 03 '16 at 10:53
  • OK, thanks for helping. – pole gar Oct 03 '16 at 11:03

1 Answers1

-1

Found it with your help of course. file=$(head -n1 $filename |sed 's/^#//')

pole gar
  • 53
  • 9
  • Absolutely not. Take another look at the comments you received and if you don't see the answer there then clarify your question to explain why not. – Ed Morton Oct 03 '16 at 10:50