I want to delete a line which has unique id at the end of the line. how to delete the line? Is there any implementation of sed or awk in php? my file structure is as follows
1 0 * * * echo -n "cron 1" > /www/apache/logs/error_log #1 0 */2 * * * /home/user/test1.pl #2 1 0 * * * echo -n "cron 2" > /www/apache/logs/error_log #3 0 */2 * * * /home/user/test2.pl #4 1 0 * * * echo -n "cron 3" > /www/apache/logs/error_log #5 0 */2 * * * /home/user/test3.pl #6
in the above example unique id is at the end of each line with "#" followed by the integer id value. How to delete a line by identifying with its unique key? Thanks.
with awk, (eg deleting #4 line )
in PHP, you can iterate the file and look for the id with regex :
"#\d+$"
, or you can split the line on whitespace and check that the last element is not the uniq number you specified.