Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Search specific pattern in file and return number of occurence Post 302535853 by dashing201 on Saturday 2nd of July 2011 08:05:40 AM
Old 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

Pattern occurence in a file

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

Help with pattern search and return

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

Perl onliner to search the last line with an occurence of a pattern

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

How to search unique occurence in a file?

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

search a string in a particular column of file and return the line number of the line

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

bash: need to have egrep to return a text string if the search pattern has NOT been found

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

Match pattern and print the line number of occurence using awk

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

Grep pattern after specific line number in a file

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

Search for a pattern and replace a space at specific position with a Character in File

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

Extract whole word preceding a specific character pattern with first occurence of the pattern

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
KAS_STRINGTOKEY(8)					       AFS Command Reference						KAS_STRINGTOKEY(8)

NAME
kas_stringtokey - Converts a character string into an octal key SYNOPSIS
kas stringtokey -string <password string> [-cell <cell name>] [-help] kas str -s <password string> [-c <cell name>] [-h] DESCRIPTION
The kas stringtokey command converts the character string specified with the -string argument into an octal string suitable for use as an encryption key. The kas command interpreter generates the octal key by using an encryption algorithm on the combination of the specified string and the name of the local cell (as recorded in the local /etc/openafs/ThisCell file). Use the -cell argument to convert a string into a key appropriate for a cell other than the local one. CAUTIONS
This command writes the key to the standard output stream, on which it can possibly be intercepted by third parties. It is not very secure to use the key in an actual Authentication Database entry. OPTIONS
-string <password string> Specifies the character string to convert into an octal key. -cell <cell name> Specifies the complete Internet domain name of the cell to combine with the password string while generating the key. If this argument is omitted, the kas command interpreter determines the name of the local cell by consulting: o First, the value of the environment variable AFSCELL. o Second, the cellname in the /etc/openafs/ThisCell file on the local machine. -help Prints the online help for this command. All other valid options are ignored. OUTPUT
The output is of the following form: Converting I<password string> in realm 'I<cell_name>' yields key='I<key>'. EXAMPLES
The following example shows the octal key equivalent of the string "new_pswd" in the ABC Corporation cell. % kas stringtokey new_pswd Converting new_pswd in realm 'ABC.COM' yields key='346307364320263233342354'. PRIVILEGE REQUIRED
None, and no password is required. SEE ALSO
ThisCell(5), kas(8) 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 KAS_STRINGTOKEY(8)
All times are GMT -4. The time now is 03:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy