Sponsored Content
Top Forums Shell Programming and Scripting How to remove part of the line from start of the line? Post 302997955 by apmcd47 on Tuesday 23rd of May 2017 09:51:48 AM
Old 05-23-2017
Code:
sed -n '/signature Base64/ s/.*: //p;Q'

will search for the first occurrence of signature Base64; deleted everything before the colon-space; print; exit.
Subsequent occurrences of signature Base64 will be ignored.

BUG: if the signature contains colon-space it will be cut. But that shouldn't happen for the data you are using it with.

Andrew

PS I should mentions that the Q in the sed command is a GNU extension and will not work with Unix sed.

Last edited by apmcd47; 05-23-2017 at 11:04 AM.. Reason: Forgot to say the Q command is an extension to sed
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove part of a line

Hi I need some help with using shell script to analyze the content of a file. I hope someone can help me. I have a file with content like the following: /foldera/database/procedure/a.proc$$/version1/2 /folderb/database/procedure/proj1/b.proc$$/version2/2 I need to write a shell script to... (16 Replies)
Discussion started by: tiger99
16 Replies

2. Shell Programming and Scripting

sed remove last 10 characters of a line start from 3rd line

hello experts, I need a sed command that remove last 10 characters of a line start from 3rd line. any suggestions? Thanks you (7 Replies)
Discussion started by: minifish
7 Replies

3. Shell Programming and Scripting

Using Sed to remove part of line with regex

Greetings everyone. Right now I am working on a script to be used during automated deployment of servers. What I have to do is remove localhost.localdomain and localhost6.localdomain6 from the /etc/hosts file. Simple, right? Except most of the examples I've found using sed want to delete the entire... (4 Replies)
Discussion started by: msarro
4 Replies

4. Shell Programming and Scripting

How to start reading from the nth line till the last line of a file.

Hi, For my reuirement, I have to read a file from the 2nd line till the last line<EOF>. Say, I have a file as test.txt, which as a header record in the first line followed by records in rest of the lines. for i in `cat test.txt` { echo $i } While doing the above loop, I have read... (5 Replies)
Discussion started by: machomaddy
5 Replies

5. Shell Programming and Scripting

Remove certain lines from file based on start of line except beginning and ending

Hi, I have multiple large files which consist of the below format: I am trying to write an awk or sed script to remove all occurrences of the 00 record except the first and remove all of the 80 records except the last one. Any help would be greatly appreciated. (10 Replies)
Discussion started by: nwalsh88
10 Replies

6. Shell Programming and Scripting

Reading text file, comparing a value in a line, and placing only part of the line in a variable?

I need some help. I would like to read in a text file. Take a variable such as ROW-D-01, compare it to what's in one line in the text file such as PROD/VM/ROW-D-01 and only input PROD/VM into a variable without the /ROW-D-01. Is this possible? any help is appreciated. (2 Replies)
Discussion started by: xChristopher
2 Replies

7. Shell Programming and Scripting

Reading line by line from live log file using while loop and considering only those lines start from

Hi, I want to read a live log file line by line and considering those line which start from time stamp; Below code I am using, which read line but throws an exception when comparing line that does not contain error code tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Discussion started by: ketanraut
2 Replies

8. Shell Programming and Scripting

awk to remove lines that do not start with digit and combine line or lines

I have been searching and trying to come up with an awk that will perform the following on a converted text file (original is a pdf). 1. Since the first two lines are (begin with) text they are removed 2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Discussion started by: cmccabe
3 Replies

9. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies
OPENSSL_VERIFY(3)							 1							 OPENSSL_VERIFY(3)

openssl_verify - Verify signature

SYNOPSIS
int openssl_verify (string $data, string $signature, mixed $pub_key_id, [mixed $signature_alg = OPENSSL_ALGO_SHA1]) DESCRIPTION
openssl_verify(3) verifies that the $signature is correct for the specified $data using the public key associated with $pub_key_id. This must be the public key corresponding to the private key used for signing. PARAMETERS
o $data - The string of data used to generate the signature previously o $signature - A raw binary string, generated by openssl_sign(3) or similar means o $pub_key_id - resource - a key, returned by openssl_get_publickey(3) string - a PEM formatted key, example, "-----BEGIN PUBLIC KEY----- MIIBCgK..." o $signature_alg - int - one of these Signature Algorithms. string - a valid string returned by openssl_get_md_methods(3) example, "sha1WithRSAEn- cryption" or "sha512". RETURN VALUES
Returns 1 if the signature is correct, 0 if it is incorrect, and -1 on error. CHANGELOG
+--------+------------------------------------------+ |Version | | | | | | | Description | | | | +--------+------------------------------------------+ | 5.2.0 | | | | | | | The $signature_alg parameter was added. | | | | +--------+------------------------------------------+ EXAMPLES
Example #1 openssl_verify(3) example <?php // $data and $signature are assumed to contain the data and the signature // fetch public key from certificate and ready it $pubkeyid = openssl_pkey_get_public("file://src/openssl-0.9.6/demos/sign/cert.pem"); // state whether signature is okay or not $ok = openssl_verify($data, $signature, $pubkeyid); if ($ok == 1) { echo "good"; } elseif ($ok == 0) { echo "bad"; } else { echo "ugly, error checking signature"; } // free the key from memory openssl_free_key($pubkeyid); ?> Example #2 openssl_verify(3) example <?php //data you want to sign $data = 'my data'; //create new private and public key $private_key_res = openssl_pkey_new(array( "private_key_bits" => 2048, "private_key_type" => OPENSSL_KEYTYPE_RSA, )); $details = openssl_pkey_get_details($private_key_res); $public_key_res = openssl_pkey_get_public($details['key']); //create signature openssl_sign($data, $signature, $private_key_res, "sha1WithRSAEncryption"); //verify signature $ok = openssl_verify($data, $signature, $public_key_res, OPENSSL_ALGO_SHA1); if ($ok == 1) { echo "valid"; } elseif ($ok == 0) { echo "invalid"; } else { echo "error: ".openssl_error_string(); } ?> SEE ALSO
openssl_sign(3). PHP Documentation Group OPENSSL_VERIFY(3)
All times are GMT -4. The time now is 11:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy