I'm trying to read a .csr file into a string, but I don't want the first and last line of the file.
I've tried reading the file into a string and then splitting it into an array, but I can't get the syntax to work.
I've also tried reading it into a string and then stripping away the first and last line (they never change), but I've had the same issue.
I'm new to bash and just need this script written, any help would be appreciated.
The file is test.csr and looks like this:
-----BEGIN CERTIFICATE REQUEST-----
TESTESTESTESTESTESTSETESTEESSTSETESTTESTES
TESTESTESTESTESTESTSETESTEESSTSETESTTESTES
...
-----END CERTIFICATE REQUEST-----
As an attempt for stripping I used
csrFile=`cat server.csr`
#echo "$csrFile"
#csrFile=${csrFile##*-----BEGIN CERTIFICATE REQUEST----- }
#csrFile=${csrFile%% -----END CERTIFICATE REQUEST-----*}
#echo "$csrFile"
But when I echoed this out, the entire string was still intact
My attempt for splitting into an array
readarray -t my_array <<<"$csrFile"
echo "$my_array"
echo "$csrFile"
( IFS=$'\n'; echo "${csrFile[*]}" )
But this didn't print anything out