Sponsored Content
Top Forums Shell Programming and Scripting sed - searching token in certain order Post 302854079 by jcdole on Monday 16th of September 2013 05:30:59 PM
Old 09-16-2013
My last post show what I have tried before I post my question.

And the pseudo code show exactly the problem:
1°) There is one parameter ($1) for the file name : "/root/Documents/file_text.txt" in the example
2°) There is one parameter ($2) for the first token : "In the Linux startup process" in the example
So we can ignore the begin of the text file
3°) There is one parameter ($3) for the second token : "Like init"
So we can search safely from this second token because we are protected by the first token and because we know that the second token appear only once after the first token. So we can ignore all the text until this second token after having found the first token.
4°) There is one parameter ($5) for the last token : "ways" in the example
So we stop searching beyond this token.
As I have no idea how to pass the character " \ " or " } " or " ' " or " . " as token, I have make my test with a single word.
5°) There is one parameter ($4) for the token to search for : "manage" in the example.
This token could start at the very beginning of a line, after a blank or after a tab ( some thing like [ ^ | \t | ]).
As I don't know how to represent this ORed expression, I give my example with a simple word.

As you can see, my pseudo code is unchanged.

What I would like is :
1°) make simpler
Code:
my_function () {
CMD="COUNT=\$(sed -n '/^$1/,\$p'  $2 | sed -n '/^$3/,\$p' | sed '/$5/ q'  | sed -n '1p' | grep -c '$4'   )"
eval $CMD
if [[ $COUNT -gt 0 ]] ; then
    return 0
else
    return 1
fi
}

2°) how to pass a \, a }, a ' as $5
3°) how to pass [^ | \t | space ]token_to_pass as $4
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

using sed and regex to reverse order???

so i have been trying to learn how to manipulate text on my own and have gotten stumped... let's say i have a text file that says (highly simplified): people ordinary How would swap the order of the words.. I know i need to use sed and some kind of back reference but cannot make it... (2 Replies)
Discussion started by: urtherhoda
2 Replies

2. UNIX for Dummies Questions & Answers

Changing the order using sed

I have a text "abc def ghi" and I want to get it as "def abc ghi" I am using this echo "abc def ghi" | sed 's/\(*\)\(*\)/\2\1/' But I am not able to get the output, could anyone help me. Thanks (9 Replies)
Discussion started by: venu_nbk
9 Replies

3. Shell Programming and Scripting

sed searching across lines

hi, i'm making now a bash script, that runs some compiler... i want to take only errors form its output eg: output: bla bla bla ... erros is 1324546 the bla bla bla bla bla bla... ... and i want to get only erros is 1324546 the bla bla bla (11 Replies)
Discussion started by: miechu
11 Replies

4. Shell Programming and Scripting

Reversing file order using SED

Im trying to develop a shell script that will change the content order of the file. For example I have a file that says a b c d I want to change this to be d c b a Im trying to use sed to this by reading the file and then inserting each line at the top #!/usr/bin/ksh ... (3 Replies)
Discussion started by: MBGPS
3 Replies

5. Shell Programming and Scripting

sed or awk to order a file

Hi - I have a file with lots of lines in that I need to order based on the number of commas! e.g the file looks something like :- cn=john,cn=users,cn=uk,dc=dot,dc=com cn=john,cn=users,dc=com cn=users,cn=groups,dc=com cn=john,cn=admins,cn=users,cn=uk,dc=dot,dc=com... (4 Replies)
Discussion started by: sniper57
4 Replies

6. Shell Programming and Scripting

Sed - Pattern Searching

Hi, Please take a look at the below eg. I would like to search for abc() pattern first and then search for (xyz) in the next line. If I can find the pattern, then I should delete the 3 lines. I can only find the pattern and delete but I am unable to find two patterns and delete. Any... (8 Replies)
Discussion started by: sreedevi
8 Replies

7. UNIX for Dummies Questions & Answers

Searching for multiple words on a line in any order issue

Hi again I have figured out how to be able to sort through lines in a file with multiple words in any order and display them using this command: cat file | grep -i $OPTION1 | grep -i $OPTION2 | grep -i $OPTION3 OPTION1 is 2008, OPTION2 is Mar, OPTION 3 is Tue Result: Tue Mar 25... (4 Replies)
Discussion started by: semaj
4 Replies

8. Shell Programming and Scripting

sed - Removing all characters from token to end of line

Hello. The token is any printable characters between 2 " . The token is unknown, but we know that it is between 2 " Tok 1 : "1234x567" Tok 2 : "A3b6+None" Tok 3 : "A3b6!1234=@" The ligne is : Line 1 : "9876xABCDE"Do you have any code fragments or data samples in your post Line 2 : ... (3 Replies)
Discussion started by: jcdole
3 Replies

9. Shell Programming and Scripting

sed string with any order

Hi, i have a strange prob. log file contains ip, protocol, user name, agent . these can be in any order. If log contains the above order able to fetch all details but if details are in diff order not able to fetch all details. using below command. grep -A50 "Entry " "/logs/file.log" \ |grep... (6 Replies)
Discussion started by: Satyak
6 Replies

10. Shell Programming and Scripting

Searching for a token in a file

Hi All, I am new to scripting. I have a requirement where I need to search for token present in array in a file. If the token is found I need to take the first column of that line from the file and append it to token and direct it to a new file. e.g. token file token.txt contains abc... (2 Replies)
Discussion started by: alok2082
2 Replies
PKCSICSF(1)							   openCryptoki 						       PKCSICSF(1)

NAME
pkcsicsf - configuration utility for the ICSF token SYNOPSIS
pkcsicsf [-h] [-l|-a token name] [-b BINDDN] [-c client-cert-file] [-C CA-cert-file] [-k privatekey] [-m mechanism] [-u URI] DESCRIPTION
The pkcsicsf utility lists available ICSF tokens and allows user to add one specific ICSF token to opencryptoki. The ICSF token must be added first to opencryptoki. This creates an entry in the opencryptoki.conf file for the ICSF token. It also creates a token_name.conf configuration file in the same directory as the opencryptoki.conf file, containing ICSF specific information. This information is read by the ICSF token. The ICSF token must bind and authenticate to an LDAP server. The supported authentication mechanisms are simple and sasl. One of these mechanisms must be entered when listing the available ICSF tokens or when adding an ICSF token. Opencryptoki currently supports adding only one ICSF token. The system admin can either allow the ldap calls to utilize exisiting ldap configs, such as ldap.conf or .ldaprc for bind and authentica- tion information or set the bind and authentication information within opencryptoki by using this utility and its options. The information will then be placed in the token_name.conf file to be used in the ldap calls. When using simple authentication, the user will be prompted for the racf password when listing or adding a token. OPTIONS
-a token name add the specified ICSF token to opencryptoki. -b BINDND the distinguish name to bind when using simple authentication -c client-cert-file the client certificate file when using SASL authentication -C CA-cert-file the CA certificate file when using SASL authentication -h show usage information -k privatekey the client private key file when using SASL authentication -m mechanism the authentication mechanism to use when binding to the LDAP server (this should be either simple or sasl) -l list available ICSF tokens -h show usage information FILES
/etc/opencryptoki/opencryptoki.conf the opencryptoki config file containing token configuration information /etc/opencryptoki/token_name.conf contains ICSF configuration information for the ICSF token SEE ALSO
opencryptoki(7), pkcsslotd(8). pkcsconf(8). 3.0 April 2013 PKCSICSF(1)
All times are GMT -4. The time now is 02:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy