The question is related to the question "Unix: Add a Tag to the beginning of each file?".
How can I put the tag only to the files that do not contain the tag, such as <?php, already?
|
The question is related to the question "Unix: Add a Tag to the beginning of each file?". How can I put the tag only to the files that do not contain the tag, such as | |||
|
feedback
|
head -n1 file | grep -q "^<?php" || sed -i "1s/^/<?php /" file | |||
|
feedback
|
|
Suitably modified version of my answer to the original question:
Running this command with Edit: Updated the match from | ||||
|
feedback
|
|
You want || (OR). If the left hand is true, it will not bother with the right hand. e.g.
| ||||
feedback
|