New answers tagged replacement
If you really don't need to search through the output file and make changes to it, then it would be easier to just change what you write to it in the first place. With this bit of script, if the command is successful and returns an exit code of "0", then "correct" will be written to your file: "/file.txt". If the command returns any other exit code, that ...
If you want to replace only the lines containing '0' and nothing else, use: sed -i 's/^0$/correct/g' file.txt Where ^ and $ are special characters signalling the beginning and the end of the line respectively. A potential issue could be if there are any other rows in the file only containing '0', not just the $? return values. A way to improve this would ...
From your code snippet, the sed expression looks correct - it will replace every '0' character with the characters 'correct'. If you only want the output from your echo command to be updated, you could put the sed command on the output from echo, eg: some command date >> /file.txt echo $? | sed 's/0/correct/' >> /file.txt (note removing 'echo' and 'cat' ...
If it's a ribbon cable and not a plug that won't stay in, just use a little masking tape to hold the cable in place.
Top 50 recent answers are included