Question: After running

> 
> test=$(security 2>&1 >/dev/null find-generic-password -ga test) echo
>  $test
> 
> 
> 

The output is 

> 
> password: "1234"
> 
> 
> 

I would like to remove everything and only leave the actual password, in these case just 

> 
> 1234
> 
> 
> 

Any help?

Answer: 
If the format is always `password: "value"`, you can do this **efficiently** without any external utility using just substring expansion:

```
echo "${test:11:-1}" #output: 1234

```

If you insist on using other utilities:

```
awk -F'"' '{ print $2 }' <<< "$test" #output: 1234
cut -d'"' -f2 <<< "$test" #output: 1234

```

Both commands above will fail if you have a `"` character in your password. Another solution using `sed` working fine with `"` in your password:

```
sed 's/^password: "\(.*\)"$/\1/' <<< "$test" #output: 1234

```
Use a Perl-Compatible Regular Expression with Grep
--------------------------------------------------

If your system has a grep compiled with the PCRE engine (e.g. pcregrep, or support for `grep -P`) then you can drop `pcregrep -o ': "\K[^"]+'` into your pipeline. For example, to send just the material between the quotes to standard output:

```
$ echo 'password: "1234"' | pcregrep -o ': "\K[^"]+'
1234

$ echo 'password: "ABCD"' | pcregrep -o ': "\K[^"]+'
ABCD

$ echo 'password: "1A2B3C4D"' | pcregrep -o ': "\K[^"]+'
1A2B3C4D

```