By using sed (or grep if sed doesn't support functions), I am searching how to copy only letters, points (.), spaces, and numbers on a specific line of text file and send the sed output to a var; I don't want to cut part of the text.
I want sed to just read the specified line of the text file, and copy only the a-z, A-Z, 0-9 characters and ". " symbols.
By browsing several webpages and the GNU man page of SED: https://www.gnu.org/software/sed/manual/sed.html
I am trying to do that with this command:
NAME1=$(sed -n '1p' -e 's/.*\[:alpha:digit:blank:punct:]/`\1/p`' txtfile)
But i get this an not really cleared error message:
test.sh: 1: [: sed: unexpected operator
I don't remember how to indicate several types of "Character Classes and Bracket Expressions" in a sed command, and also I am not sure of my usage of
-n option location to indicate to sed on which line number of text it must work.
\1/p argument/option to indicate to sed that the matched pattern(s) (if sed finds something) must be kept in the original file.