Sponsored Content
Top Forums Shell Programming and Scripting help with Scripting - trying to search for string and extract next few characters Post 302487634 by LonJ_80 on Thursday 13th of January 2011 04:46:59 AM
Old 01-13-2011
help with Scripting - trying to search for string and extract next few characters

Hi
I am new to world on unix scripting so any assistance would be gratefully appreciated,
I am trying to write a script which reads through a file, reads in line by line, searches for a pattern, copies string after it and then to do a search and replace elsehwere in the line,

so the input file would readsomething like
Code:
Value1:"alpha" Value2:"beta" Value3:"delta" Value4:"gamma" 
Value1:"bravo" Value2:"charlie" Value3:"echo" Value4:"sierra"

and i would want to extract the value3 from each line i.e "delta" and "echo" and replace Value2 with NewValue:extractedvalue Value2

so after runing the script the file shows
Code:
Value1:"alpha" NewValue:"delta" Value2:"beta" Value3:"delta" Value4:"gamma" 
Value1:"bravo" NewValue:"echo" Value2:"charlie" Value3:"echo" Value4:"sierra"


Moderator's Comments:
Mod Comment Please use code tags when posting data and code samples, thank you!

Last edited by Franklin52; 01-13-2011 at 05:57 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract string between two different characters

I want to extract a string from a line in a text file between two different characters: for example: :string" I want to extract string. It has to be done in a one-liner. (11 Replies)
Discussion started by: rein
11 Replies

2. Shell Programming and Scripting

Search for string in a file and extract another string to a variable

Hi, guys. I have one question: I need to search for a string in a file, and then extract another string from the file and assign it to a variable. For example: the contents of the file (group) is below: ... ftp:x:23: mail:x:34 ... testing:x:2001 sales:x:2002 development:x:2003 ...... (6 Replies)
Discussion started by: daikeyang
6 Replies

3. Shell Programming and Scripting

Extract upper case characters from a string

Hi Friends, I have a script which returns me the following values line by line ora_smon_RCAT102 oracleKHP102B (DESC oraclePROOIDDB92 (DES oraclePMS (DESCRIP oracleBRIO (LOCAL=N oracleBRIO (LOCAL=N oraclePRDB92 (DES oracleBRIO (LOCAL=N oracleBRIO (LOCAL=N oraclePMS (DESCRIP... (4 Replies)
Discussion started by: orakhan
4 Replies

4. Shell Programming and Scripting

Search a String for characters - or +

How would I accomplish this if I want to test to see if it 1) starts with a dash so something like "-R" AND 2) starts with 1 character then either a "-" or "+" and then up to 3 characters such as "a+rx" (3 Replies)
Discussion started by: mkjp2011
3 Replies

5. Shell Programming and Scripting

Extract string between 2 special characters

Hi, I have a unix file with contents as below Line1: ABC MNN X$$QWERTY$$ JKL Line2: HELLO $$HOW$$ ARE $$YOU$$ DOING i want to extract the string between $$ and $$ ie i want the output as QWERTY HOW YOU i want those strings seperated by some character say | desired output is... (7 Replies)
Discussion started by: vinredmac
7 Replies

6. Shell Programming and Scripting

Search String and extract few lines under the searched string

Need Assistance in shell programming... I have a huge file which has multiple stations and i wanted to search particular station and extract few lines from it and the rest is not needed Bold letters are the stations . The whole file has multiple stations . Below example i wanted to search... (4 Replies)
Discussion started by: ajayram_arya
4 Replies

7. Shell Programming and Scripting

To Search for a string and to extract the string from the text

Hi Team I have an huge xml where i need to search for a ceratin numbers. For example 2014-05-06 15:15:41,498 INFO WebContainer : 10 CommonServicesLogs - CleansingTriggerService.invokeCleansingService Entered PUBSUB NOTIFY MESSAGE () - <?xml version="1.0" encoding="UTF-8"... (5 Replies)
Discussion started by: Kannannair
5 Replies

8. UNIX for Dummies Questions & Answers

Extract string between two special characters

Hi, I have a file that looks something like >1-18*anc... (12 Replies)
Discussion started by: jyu429
12 Replies

9. Shell Programming and Scripting

Need to extract characters between two search words in a script!!

Hi, I have a log file which is the output from a xml script : <?xml version="1.0" ?> <!DOCTYPE svc_result SYSTEM "MLP_SVC_RESULT_320.DTD"> <svc_result ver="3.2.0"> <slia ver="3.0.0"> <pos> <msid type="MSISDN" enc="ASC">8093078040</msid> <poserr> ... (4 Replies)
Discussion started by: arjunstarz
4 Replies

10. UNIX for Beginners Questions & Answers

Extract characters from a string name

Hi All, I am trying to extract only characters from a string value eg: abcdedg1234.cnf How can I extract only characters abcdedg and assign to a variable. Please help. Thanks (2 Replies)
Discussion started by: abhi_123
2 Replies
rmdel(1)						      General Commands Manual							  rmdel(1)

NAME
rmdel - remove a delta from an SCCS file SYNOPSIS
SID file ... DESCRIPTION
The command removes the delta specified by the SID from each named SCCS file. The delta to be removed must be the newest (most recent) delta in its branch in the delta chain of each named SCCS file. In addition, the SID specified must be that of a version being edited for the purpose of making a delta (i.e., if a p-file (see get(1)) exists for the named SCCS file, the SID specified must appear in any entry of the p-file). If a directory is named, behaves as though each file in the directory were specified as a named file, except that non-SCCS files (last com- ponent of the path name does not begin with and unreadable files are silently ignored. If a name of is given, the standard input is read; each line of the standard input is taken to be the name of an SCCS file or directory to be processed; non-SCCS files and unreadable files are silently ignored. When is specified on the command line, all following arguments are treated as file names. The permissions to remove a delta are either (1) if you make a delta you can remove it; or (2) if you own the file and directory you can remove a delta. EXTERNAL INFLUENCES
Environment Variables determines the locale for the interpretation of text as single-byte and/or multi-byte characters. determines the language in which messages are displayed. also determines the local language equivalent of the affirmative string ("yes"). If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single-byte and multi-byte character code sets are supported. DIAGNOSTICS
Use sccshelp(1) for explanations. FILES
See delta(1). See delta(1). SEE ALSO
delta(1), get(1), sccshelp(1), prs(1), sccsfile(4). STANDARDS CONFORMANCE
rmdel(1)
All times are GMT -4. The time now is 05:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy