OS : RHEL 7.9
Shell : bash
In the below file (somestrings.txt) , I want to retrieve the lines with the pattern "Aug 6". I think there are 2 spaces in the middle.
I tried to escape the space using \ and \+ characters. But, it did not work as shown below.
Any idea what am I missing ?
$ cat somestrings.txt
-rw-------. 1 oracle oinstall 312475648 Aug 6 09:44 LOG_ORCL_1_35890_1062507603.arc
-rw-r-----. 1 oracle oinstall 389392384 Aug 6 05:17 LOG_ORCL_1_35891_1062507603.arc
-rw-r-----. 1 oracle oinstall 409188864 Aug 6 05:18 LOG_ORCL_1_35892_1062507603.arc
-rw-r-----. 1 oracle oinstall 403528704 Aug 6 05:20 LOG_ORCL_1_35893_1062507603.arc
-rw-r-----. 1 oracle oinstall 406588928 Aug 6 12:52 LOG_ORCL_1_36253_1062507603.arc
-rw-r-----. 1 oracle oinstall 426092544 Aug 6 12:53 LOG_ORCL_1_36254_1062507603.arc
-rw-r-----. 1 oracle oinstall 424885760 Aug 6 12:54 LOG_ORCL_1_36255_1062507603.arc
-rw-r-----. 1 oracle oinstall 363351040 Aug 9 08:17 LOG_ORCL_1_36455_1062507603.arc
-rw-r-----. 1 oracle oinstall 364530176 Aug 9 09:22 LOG_ORCL_1_36456_1062507603.arc
-rw-r-----. 1 oracle oinstall 427719168 Aug 9 09:25 LOG_ORCL_1_36457_1062507603.arc
-rw-r-----. 1 oracle oinstall 427726848 Aug 9 09:25 LOG_ORCL_1_36458_1062507603.arc
-rw-r-----. 1 oracle oinstall 427720704 Aug 9 09:36 LOG_ORCL_1_36459_1062507603.arc
-rw-r-----. 1 oracle oinstall 396074496 Aug 9 10:56 LOG_ORCL_1_36511_1062507603.arc
-rw-r-----. 1 oracle oinstall 441894912 Aug 9 11:56 LOG_ORCL_1_36609_1062507603.arc
$
$
$ grep "Aug\ 6" somestrings.txt
$
$ grep "Aug\+ 6" somestrings.txt
$
$ grep "Aug\+\6" somestrings.txt
grep: Invalid back reference
BTW, when you use grep utility, should I enclose the pattern in single quote or double quotes ? I always get this mixed up.