I have this file: 1.txt
===================================================================
File: .cvsignore Status: Up-to-date
Working revision: 1.1 Thu Jan 16 11:00:00 2020
Repository revision: 1.1 /usr/local/rancid/var/CVS/Routers/.cvsignore,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
===================================================================
File: router.db Status: Up-to-date
Working revision: 1.6 Fri Jan 17 11:57:39 2020
Repository revision: 1.6 /usr/local/rancid/var/CVS/Routers/router.db,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
===================================================================
File: .cvsignore Status: Up-to-date
Working revision: 1.1 Thu Jan 16 11:00:00 2020
Repository revision: 1.1 /usr/local/rancid/var/CVS/Routers/configs/.cvsignore,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
===================================================================
===================================================================
File: 1.1.1.1 Status: Up-to-date
Working revision: 1.2 Fri Jan 17 07:56:21 2020
Repository revision: 1.2 /usr/local/rancid/var/CVS/Routers/configs/1.1.1.1,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: -ko
I want to extract string between File: and Status: (.cvsignore, router.db, 1.1.1.1)
and between Repository revision: and /usr/local/rancid/ (1.1, 1.6, 1.1 )
so final output should be:
.cvsignore 1.1
router.db 1.6
.cvsignore 1.1
1.1.1.1 1.2
for filename i created following filter:
sed 's/^.*File: //; s/Status:.*$//' 1.txt
Output:
===================================================================
.cvsignore
Working revision: 1.1 Thu Jan 16 11:00:00 2020
Repository revision: 1.1 /usr/local/rancid/var/CVS/Routers/.cvsignore,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
===================================================================
router.db
Working revision: 1.6 Fri Jan 17 11:57:39 2020
Repository revision: 1.6 /usr/local/rancid/var/CVS/Routers/router.db,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
===================================================================
.cvsignore
Working revision: 1.1 Thu Jan 16 11:00:00 2020
Repository revision: 1.1 /usr/local/rancid/var/CVS/Routers/configs/.cvsignore,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
===================================================================
1.1.1.1
Working revision: 1.2 Fri Jan 17 07:56:21 2020
Repository revision: 1.2 /usr/local/rancid/var/CVS/Routers/configs/172.18.1.24,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: -ko
===================================================================
For Repository revision i'm trying
sed 's/^.'*Repository revision:' //; s#usr#local#rancid:.*$//' 1.txt
But getting
sed: -e expression #1, char 15: unterminated `s' command
I need one regex for filename and second for Repository revision
# Repository versionto be output after some of the values? If so, how do you decide which ones?file=$(awk for filename)andrepo=$(awk for Repository version)filecontain a single file name or a list of all file names? It really seems like you're thinking about this the wrong way and so heading down the wrong path here.filenameand correspondingRepository versionso i can use those variables later on in different command