Sponsored Content
Top Forums Shell Programming and Scripting Selecting a part of the text (regex pattern, awk, sed) Post 302455498 by TehOne on Tuesday 21st of September 2010 09:47:26 PM
Old 09-21-2010
Quote:
Originally Posted by rdcwayx
-F" " is useless, because it is default FS

And you need tell use your expect O/P

for example, for this string: /TEXT123/TEXT456/ABC123/

what will be TEXT and ABC?

Seems basename and dirname will help you.

---------- Post updated at 11:00 AM ---------- Previous update was at 10:55 AM ----------

Code:
cat infile |while read LINE; 
do  
  TEXT=$( echo $LINE|awk '{gsub(/"/,"");print $2}' |xargs dirname)
  ABC=$(echo $LINE|awk '{gsub(/"/,"");print $2}' |xargs basename)
done

Code:
"READ /TEXT123/ABC123"
TEXT= TEXT123
ABC= ABC123

"READ TEXT123/ABC123/"
TEXT= TEXT123
ABC= ABC123

"READ /TEXT123/TEXT456/ABC123/"
TEXT= TEXT123/TEXT456
ABC= ABC123

Oh you prolly misunderstood the " " part in my text examples, basically my script gets executed by another one and that script is passing two arguments where the first one contains my examples... so there arn't any real "" in the text... $1 = READ /TEXT123/ABC123

Last edited by TehOne; 09-21-2010 at 10:54 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Selecting line ahead and next using AWK or SED

:confused: Good Day, I have this script that gets the archive names and the time it applies based on the alert log. The application of archives are of daily basis and usually many so having this script helps my job become easier. My problem is that when i get all the time stamps and... (1 Reply)
Discussion started by: ownins
1 Replies

2. Shell Programming and Scripting

RegEx for text pattern

Hi, Please help me write regex for text pattern like CONTACT PEOPLE:first_name1.last_name1,first_name2.last_name2,first_name3.last_name3, ...so on Any advice is Okay! Thanks in advance. (6 Replies)
Discussion started by: rider29
6 Replies

3. Shell Programming and Scripting

sed to awk (regex pattern) how?

Hello, I am trying to covert a for statement into a single awk script and I've got everything but one part. I also need to execute an external script when "not found", how can I do that ? for TXT in `find debugme -name "*.txt"` ;do FPATH=`echo $TXT | sed 's/\(.*\)\/\(.*\)/\1/'` how... (7 Replies)
Discussion started by: TehOne
7 Replies

4. UNIX for Dummies Questions & Answers

blank space in regex pattern using sed

why does sed 's/.* //' show the last word in a line and sed 's/ .*//' show the first word in a line? How is that blank space before or after the ".*" being interpreted in the regex? i would think the first example would delete the first word and the next example would delete the second... (1 Reply)
Discussion started by: glev2005
1 Replies

5. Shell Programming and Scripting

Using Sed to remove part of line with regex

Greetings everyone. Right now I am working on a script to be used during automated deployment of servers. What I have to do is remove localhost.localdomain and localhost6.localdomain6 from the /etc/hosts file. Simple, right? Except most of the examples I've found using sed want to delete the entire... (4 Replies)
Discussion started by: msarro
4 Replies

6. Shell Programming and Scripting

Selecting specific 'id's from lines and columns using 'SED' or 'AWK'

Hello experts, I am new to this group and to 'SED' and 'AWK'. I have data (text file) with 5 columns (C_1-5) and 100s of lines (only 10 lines are shown below as an example). I have to find or select only the id numbers (C-1) of specific lines with '90' in the same line (of C_3) AND with '20' in... (6 Replies)
Discussion started by: kamskamu
6 Replies

7. Shell Programming and Scripting

Replacing part of a pattern in sed

Hi I have a piece of xml that has a pattern like this <int>159</int><int>30</int> I want to find this pattern but only substitute the second part of the pattern to {rid1}. Is that possible in sed ? Thanks. ---------- Post updated at 12:10 PM ---------- Previous update was at 12:01 PM... (11 Replies)
Discussion started by: vnn
11 Replies

8. Shell Programming and Scripting

SED: Pattern repitition regex matching

Fairly straightforward, but I'm having an awful time getting what I thought was a simple regex to work. I'll give the command I was playing with, and I'm aware why this one doesn't work (the 1,3 is off the A-Z, not the whole expression), I just don't know what the fix is: Actual Output(s): $... (5 Replies)
Discussion started by: Vryali
5 Replies

9. Shell Programming and Scripting

Regex in sed to find specific pattern and assign to variable

(5 Replies)
Discussion started by: radioactive9
5 Replies

10. UNIX for Advanced & Expert Users

sed REGEX to print multiple occurrences of a pattern from a line

I have a line that I need to parse through and extract a pattern that occurs multiple times in it. Example line: getInfoCall: info received please proceed, getInfoCall: info received please proceed, getInfoCall: info received please proceed, getInfoCall: info received please proceed,... (4 Replies)
Discussion started by: Vidhyaprakash
4 Replies
ALTER TEXT SEARCH 
DICTIONARY(7) PostgreSQL 9.2.7 Documentation ALTER TEXT SEARCH DICTIONARY(7) NAME
ALTER_TEXT_SEARCH_DICTIONARY - change the definition of a text search dictionary SYNOPSIS
ALTER TEXT SEARCH DICTIONARY name ( option [ = value ] [, ... ] ) ALTER TEXT SEARCH DICTIONARY name RENAME TO new_name ALTER TEXT SEARCH DICTIONARY name OWNER TO new_owner ALTER TEXT SEARCH DICTIONARY name SET SCHEMA new_schema DESCRIPTION
ALTER TEXT SEARCH DICTIONARY changes the definition of a text search dictionary. You can change the dictionary's template-specific options, or change the dictionary's name or owner. You must be the owner of the dictionary to use ALTER TEXT SEARCH DICTIONARY. PARAMETERS
name The name (optionally schema-qualified) of an existing text search dictionary. option The name of a template-specific option to be set for this dictionary. value The new value to use for a template-specific option. If the equal sign and value are omitted, then any previous setting for the option is removed from the dictionary, allowing the default to be used. new_name The new name of the text search dictionary. new_owner The new owner of the text search dictionary. new_schema The new schema for the text search dictionary. Template-specific options can appear in any order. EXAMPLES
The following example command changes the stopword list for a Snowball-based dictionary. Other parameters remain unchanged. ALTER TEXT SEARCH DICTIONARY my_dict ( StopWords = newrussian ); The following example command changes the language option to dutch, and removes the stopword option entirely. ALTER TEXT SEARCH DICTIONARY my_dict ( language = dutch, StopWords ); The following example command "updates" the dictionary's definition without actually changing anything. ALTER TEXT SEARCH DICTIONARY my_dict ( dummy ); (The reason this works is that the option removal code doesn't complain if there is no such option.) This trick is useful when changing configuration files for the dictionary: the ALTER will force existing database sessions to re-read the configuration files, which otherwise they would never do if they had read them earlier. COMPATIBILITY
There is no ALTER TEXT SEARCH DICTIONARY statement in the SQL standard. SEE ALSO
CREATE TEXT SEARCH DICTIONARY (CREATE_TEXT_SEARCH_DICTIONARY(7)), DROP TEXT SEARCH DICTIONARY (DROP_TEXT_SEARCH_DICTIONARY(7)) PostgreSQL 9.2.7 2014-02-17 ALTER TEXT SEARCH DICTIONARY(7)
All times are GMT -4. The time now is 05:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy