in Education by
fairly new to using linux on shell. I want to reduce the amount of pipes I used to extract the following data. V 190917135635Z 1005 unknown /C=DE/ST=City/L=City/O=something/OU=Somewhat/CN=someserver.com/[email protected] My goal is to put the following values into a separate file 190917135635 someserver.com The command I use right now is fairly long, piped and looks like this grep -v '^R' $file | awk '{print $2, $6}' | awk -F'[=|/]' '{print $1, $3}' | awk '{print $1, $3}' | awk -F 'Z ' '{print $1, $2}' > sdata.txt (The file contains other lines starting with 'R' so I exclude those in my grep) Is this a legit way of doing it? Is there a way to get this in a shorter command? Thanks a lot! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Another awk. Using match to find CN entry and substr to extract it for print to print, if it exists. $ awk '!/^R/{ print $2, (match($0,/CN=[^/]+/)?substr($0,RSTART+3,RLENGTH-3):"") # 3==length("CN=") }' file Output: 190917135635Z someserver.com

Related questions

0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I am using the aws cli to list the files in an s3 bucket using the following command (documentation): aws s3 ... only the file list? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I use nonblocking socket to receive new connection. But the code repeatedly fails to accept(). int sockfd = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    For instance, given ( 1, 2, 5, 6, 7), i'd like to determine that 3 and 4 are missing? ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    Installed Postgres-XC $>sudo apt-get install postgres-xc then $ postgres -V postgres (PostgreSQL) 9.2. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    For instance, given ( 1, 2, 5, 6, 7), i'd like to determine that 3 and 4 are missing? ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    in the source directory, i have some binary files named 1.bin, 2.bin, 3.bin, etc. In the dest ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    This is obviously a stupid question. I am coding in Eclipse both on Mac and Linux, but I mixed up ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Why doesnt "tail" work to truncate log files? (6 answers) Closed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Why doesnt "tail" work to truncate log files? (6 answers) Closed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: Why doesnt "tail" work to truncate log files? (6 answers) Closed ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    We currently use multiple web servers accessing one MySQL server and fileserver. Looking at moving to the cloud, ... another solution? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
...