I want a shell script that
- grabs my current screen resolution, (solved)
- searches a file for the line containing the resolution setting,
- replaces the old resolution setting in the file with the current one
So far (thanks!) I’ve got the command for getting the current screen resolution data:
system_profiler SPDisplaysDataType | awk '/Resolution/ {
print "screenwidth \""$2"\"";
print "screenheight \""$4"\"";
}'
The lines that should be written to respectively begins with:
screenwidth "VALUE1"
screenheight "VALUE2"
How do I write the results to the file on the “VALUE” positions?
(I’m quite a beginner in the world of shell scripts)
If I understood you right,
you want to replace value1/2 in old file with new values from above lines
then you could do in one shot:
see this test example: