Searching String which repeates


 
Thread Tools Search this Thread
Top Forums Programming Searching String which repeates
# 1  
Old 09-18-2012
Error Searching String which repeates

Hi All,

Any one please help me with the below scenario.
I have a file with the data like below
Code:
This is the integer variable name is <abc1>
This is the Float variable name is <abc1>
This is the integer variable name is <abc2>
This is the Float variable name is <abc2>
This is the integer variable name is <abc3>
This is the Float variable name is <abc3>
This is the integer variable name is <abc4>
This is the Float variable name is <abc4>
This is the integer variable name is <abc5>
This is the Float variable name is <abc5>

Moderator's Comments:
Mod Comment Please use code tags


I need to find the count of the each string with the string comparison of This is the integer variable name is <abc_> and This is the Float variable name is <abc_> by taking this file as input.

Thanks in Advance

Last edited by jim mcnamara; 09-18-2012 at 11:22 AM..
# 2  
Old 09-19-2012
You can extract the type and count:
Code:
sed '
    s/^This is the \([a-zA-Z0-9_]*\) variable name is <abc.*>$/\1/
    t
    d
 ' your_input_file | sort | uniq -c

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching for variable string

Hi Guys, So im trying to search for the most recent occurance of a string in the most recently updated .log file in a certain directory. The string i am searching for is a value, now if this value is greater than 800 i would like an email sent out with some text (blah blah blah). This is what... (7 Replies)
Discussion started by: hello_world
7 Replies

2. Shell Programming and Scripting

Searching for a string using loop.

Hi i am very new to shell scripting. I have got stuck on a portion on my script. Problem : I have 30 logfiles inside /home/test directory. I need to find the string "@ended today" in all the 30 logfiles and print the name of the files which did not have this string. i need to this by... (3 Replies)
Discussion started by: Soma Das
3 Replies

3. Shell Programming and Scripting

Searching a String

Hi everyone ! suppose i'm searching for a specific string in a file so it is very easy, i use the following command grep 'keyword' file_name but how to search a word which is repeated maximum number of times in a file, for example in the following text i have to search a word which is... (12 Replies)
Discussion started by: ourned
12 Replies

4. Shell Programming and Scripting

searching the required string and appending string to it.

Hi all, I have some data in the form of adc|nvhs|nahssn|njadnk|nkfds in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like adc|nvhs|nahssn||||njadnk|nkfds Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

5. Shell Programming and Scripting

Removing repeates sequences

Hai, How to remove the repeated 'Chr's in different sequences. In the given example, Chr19 is repeated in two samples with the same number i.e. +52245923. How to remove one of the entry in any of the samples and to give the range for each Chr which is -20 for minimum range value and +120 for... (1 Reply)
Discussion started by: hravisankar
1 Replies

6. Shell Programming and Scripting

searching a text string for n'th :

hello, i'm a novice on bsh scripting so thanks for any help here basically i have a shell var $x that looks like this > echo $x nabc1234:!:73394:17155:Gary Mason:/home/garym:/bin/ksh and i'm trying to keep the first 8 characters and the text from the 4th : to the 5th : i've been trying... (9 Replies)
Discussion started by: sasglm
9 Replies

7. Shell Programming and Scripting

Searching a string in a file

Hi, I am new to unix shell scripting. I have a requirement. Could anyone help me writing the script for the same? Here goes the requirement: I have a config file let's say temp.config. Here is the data in the config file temp.config : ------------- name=victor age=42 state=texas... (5 Replies)
Discussion started by: badrimohanty
5 Replies

8. UNIX for Dummies Questions & Answers

searching for a string in a file

I need to search for a specific string in a file and if this string exist I need to replace it with something else. I am not sure how I could do this, using an if statement. (2 Replies)
Discussion started by: ROOZ
2 Replies

9. UNIX for Dummies Questions & Answers

Searching for a string variable

Hi ... I have a string variable STR = "This is a test message" I have a file abc.txt that I am searching for the occurence of the string STR ... I am using the command in a script cat abc.txt | grep $STR It identifies each space as a seperator and prints word by word. How to... (2 Replies)
Discussion started by: mattrix
2 Replies

10. Shell Programming and Scripting

Extracting a string from one file and searching the same string in other files

Hi, Need to extract a string from one file and search the same in other files. Ex: I have file1 of hundred lines with no delimiters not even space. I have 3 more files. I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies
Login or Register to Ask a Question