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
DROP TEXT SEARCH 
TEMPLATE(7) SQL Commands DROP TEXT SEARCH TEMPLATE(7) NAME
DROP TEXT SEARCH TEMPLATE - remove a text search template SYNOPSIS
DROP TEXT SEARCH TEMPLATE [ IF EXISTS ] name [ CASCADE | RESTRICT ] DESCRIPTION
DROP TEXT SEARCH TEMPLATE drops an existing text search template. You must be a superuser to use this command. PARAMETERS
IF EXISTS Do not throw an error if the text search template does not exist. A notice is issued in this case. name The name (optionally schema-qualified) of an existing text search template. CASCADE Automatically drop objects that depend on the text search template. RESTRICT Refuse to drop the text search template if any objects depend on it. This is the default. EXAMPLES
Remove the text search template thesaurus: DROP TEXT SEARCH TEMPLATE thesaurus; This command will not succeed if there are any existing text search dictionaries that use the template. Add CASCADE to drop such dictionar- ies along with the template. COMPATIBILITY
There is no DROP TEXT SEARCH TEMPLATE statement in the SQL standard. SEE ALSO
ALTER TEXT SEARCH TEMPLATE [alter_text_search_template(7)], CREATE TEXT SEARCH TEMPLATE [create_text_search_template(7)] SQL - Language Statements 2010-05-14 DROP TEXT SEARCH TEMPLATE(7)
All times are GMT -4. The time now is 10:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy