I’d like to return a specific line from the EXIT CODE section of a man page, given a valid exit code.
For example, if I run curl in a script and it returns an exit code of 2, I’d like to return the line from the curl man page:
2 Failed to initialize.
So far I’ve tried to pipe the output of man curl to grep like so:
Assuming $RETCODE=${?} after running a curl command…
lewis@hostname:~$ man curl | grep "${RETCODE}"
http://www.letters.com/file[a-z:2].txt
in the format "NAME1=VALUE1; NAME2=VALUE2".
out to be in text mode for win32 systems.
from outputting that and return error 22.
re-use the same IP address it already uses for the control connection. (Added in 7.14.2)
...
...
But this picks up a ton of other text featuring the number. Given that the exit code section is indented I have tried
lewis@hostname:~$ man curl | grep " ${RETCODE}"
2) On windows, if there is no _curlrc file in the home dir, it
2 Failed to initialize.
227-line.
21 FTP quote error. A quote command returned error from the server.
...
And as you can see, we’re close. The text I’d like is there but it still returns incorrect results.
Note, for exit codes with two or more digits the white space to the right of the number in the man pages is reduced.
Try: