07-02-2011
Search specific pattern in file and return number of occurence
Hi
I want to search for a specific pattern in file
Say
ABC;HELLO_UNIX_WORLD;PQR
ABC;HELLO_UNIX_WORLD_IS_NOT_ENOUGH;XYZ
ABC;HELLO_UNIX_FORUM;LMN
Pattern to search is : "HELLO_UNIX_*****" and not "HELLO_UNIX_***_***_"
I mean after "HELLO_UNIX" there can only be one word.In this case only WORLD and only FORUM qualifies. So output should be 2 in this case. As second row has more words after "HELLO_UNIX_"
Thanks in advance.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
How can we find the number of occurence of a specified pattern in a file?
This command would be a part of a shell script. (5 Replies)
Discussion started by: videsh77
5 Replies
2. Shell Programming and Scripting
I would like to write a script which will read a file containing a list of filenames of the format as shown below :
/usr/local/packages/runcmdlinetool
/home/john.doe/sdfsdf/sdfsdfsd/sdfsdf/sdfsdfTemplates.xml
/usr/local/bin/gtar... (4 Replies)
Discussion started by: inditopgun
4 Replies
3. Shell Programming and Scripting
Hi
I need a perl onliner which seaches a line starting with a pattern(last occurence) and display it.
similar to
grep 'pattern' filename | tail -1 in UNIX
Ex: I want to display the line starting with "cool" and which is a last occurence
adadfadafadf
adfadadf
cool dfadfadfadfara... (4 Replies)
Discussion started by: ammu
4 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I have to search and count unique occurence of DE numbers in bold below in a file which has content like below.
Proc Tran F-BUY
Item Tkey Q5JV
Item Tsid JTIZ9
Item Tdat 20091001
Item Tset 20091001
Item Tbkr 5
Item Tshs 2
Item Tprc 897.0
Item Tcom 2000.0
Item Tcm1 20091001... (6 Replies)
Discussion started by: akash028
6 Replies
5. Shell Programming and Scripting
Hi All,
Can you please guide me to search a string in a particular column of file and return the line number of the line where it was found using awk. As an example :
abc.txt
7000,john,2,1,0,1,6
7001,elen,2,2,0,1,7
7002,sami,2,3,0,1,6
7003,mike,1,4,0,2,1
8001,nike,1,5,0,1,8... (3 Replies)
Discussion started by: arunshankar.c
3 Replies
6. Shell Programming and Scripting
Hello all,
after spending hours of searching the web I decided to create an account here. This is my first post and I hope one of the experts can help.
I need to resolve a grep / sed / xargs / awk problem.
My input file is just like this:
----------------------------------... (6 Replies)
Discussion started by: bash4ever
6 Replies
7. Shell Programming and Scripting
Hi,
I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example:
inputfile
abd abp 123
abc abc 325
ndc ndc 451
mjk lkj... (3 Replies)
Discussion started by: redse171
3 Replies
8. Shell Programming and Scripting
Hi guys,
I am running a while loop in a script ro read a file line by line.
Now I want to run a grep only on the lines below the line I am that is being read by the while loop.
Eg:
If my while loop is on line 4 of the file, the grep only runs below line 4 and does not include line 1,2... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies
9. Post Here to Contact Site Administrators and Moderators
In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123.
So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
3 Replies
10. Shell Programming and Scripting
Hello.
Here is a file contents :
declare -Ax NEW_FORCE_IGNORE_ARRAY=(="§" ="§" ="§" ="§" ="§" .................. ="§"Here is a pattern
=I want to extract 'NEW_FORCE_IGNORE_ARRAY' which is the whole word before the first occurrence of pattern '='
Is there a better solution than mine :... (3 Replies)
Discussion started by: jcdole
3 Replies
LEARN ABOUT DEBIAN
tokens
TOKENS(1) AFS Command Reference TOKENS(1)
NAME
tokens, tokens.krb - Displays the issuer's tokens
SYNOPSIS
tokens [-help]
tokens [-h]
tokens.krb [-help]
tokens.krb [-h]
DESCRIPTION
The tokens command displays all tokens (tickets) cached on the local machine for the issuer. AFS server processes require that their
clients present a token as evidence that they have authenticated in the server's local cell.
The (mostly obsolete) tokens.krb command is the same as tokens except that it also displays the user's Kerberos v4 ticket cache.
OPTIONS
-help
Prints the online help for this command. All other valid options are ignored.
OUTPUT
The output lists one token for each cell in which the user is authenticated. The output indicates the
o User's AFS UID, if it is available for display.
o Server for which the token is valid (normally, afs). This includes a cell specification.
o Day and time the token expires.
The output of the Kerberos version of this command, tokens.krb, also reports the following about the Kerberos ticket-granting ticket: the
ticket owner, which Kerberos ticket-granting service that issued the ticket (for example, "krbtgt.ABC.COM"), and ticket's expiration date.
The string "--End of list--" appears at the end of the output. If the user is not authenticated in any cell, this line is all that appears.
EXAMPLES
The following example shows the output when the issuer is not authenticated in any cell.
% tokens
Tokens held by the Cache Manager:
--End of list--
The following example shows the output when the issuer is authenticated in ABC Corporation cell, where he or she has AFS UID 1000.
% tokens
Tokens held by the Cache Manager:
User's (AFS ID 1000) tokens for afs@abc.com [Expires Jan 2 10:00]
--End of list--
The following example shows the output when the issuer is authenticated in the ABC Corporation cell, the State University cell, and the XYZ
Company cell. The user has different AFS UIDs in the three cells. Tokens for last cell are expired:
% tokens
Tokens held by the Cache Manager:
User's (AFS ID 1000) tokens for afs@abc.com [Expires Jan 3 10:00]
User's (AFS ID 4286) tokens for afs@stateu.edu [Expires Jan 3 1:34]
User's (AFS ID 22) tokens for afs@xyz.com [>>Expired<]
--End of list--
The following example shows the output when the issuer uses the tokens.krb version of the command after authenticating in the ABC
Corporation cell using the klog.krb command.
% tokens.krb
Tokens held by the Cache Manager:
User's (AFS ID 1000) tokens for afs@abc.com [Expires Jan 31 00:09]
User smiths tokens for krbtgt.ABC.COM@abc.com [Expires Jan 31 00:09]
--End of list--
PRIVILEGE REQUIRED
None
SEE ALSO
klog(1), unlog(1)
COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved.
This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas
Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell.
OpenAFS 2012-03-26 TOKENS(1)