how i can use a WORD for seperator


 
Thread Tools Search this Thread
Operating Systems Solaris how i can use a WORD for seperator
# 1  
Old 02-09-2006
how i can use a WORD for seperator

hi,

i want to use A WORD for seperator in awk or especially in cut. how i can perform this. is there any way to use a word for seperator.

For example: i want to list all word after FROM and the files name contains this word.

chatnorollback.svc: delete from info where nick
chatnorollback.svc: delete from webbilling where
chatnorollback.svc: delete from webbilling where
chatnorollback.svc: sql {delete from login where
chatnorollback.svc: sql {delete from odablack
chatnorollback.svc: sql {delete from blacklist
chatnorollback.svc: sql {delete from info where
chatnorollback.svc: sql {delete from register

thanks in advance,
# 2  
Old 02-09-2006
Not really, but this might help.


Code:
sed -n 's/^\([^ ][^ ]*\).*from/\1/p' file.txt

# 3  
Old 02-09-2006
Set the awk built-in variable FS (Field Separator) to the value you want...
Code:
awk -v FS=from '{print $2}' file.txt

The details are in the awk manual: Specifying how Fields are Separated
# 4  
Old 02-10-2006
Ygor, of course you're correct. I had some strange notion in my head about only being able to use on char as the FS.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Field seperator with awk

Hi, input data format: echo ' <APPLICATION="APPLSG" SUB_APPLICATION="DLY" JOBNAME="DPL_BN_RE_CCMS_SA" CMDLINE="run_job.ksh %%PARAM1 %%PARAM2" TASKTYPE="Command" />' expected format: "APPLSG", "DLY", "DPL_BN_RE_CCMS_SA", "run_job.ksh %%PARAM1 %%PARAM2" my command: echo ' ... (2 Replies)
Discussion started by: JSKOBS
2 Replies

2. Shell Programming and Scripting

How to replace only \n( line seperator ) not Data \n?

Unix File is pipe delimited with 17 fields. We may get extra pipes in data also. We may get \n char (1 or more \n in one field or multi fileds) in data in any field. Need to replace \n true ( line separator) with 'space and bell char space' chars (' \a ') Not data \n. Input:... (1 Reply)
Discussion started by: rajeshkumare
1 Replies

3. UNIX for Beginners Questions & Answers

How to extract when filename contains file seperator..?

Hi, I want to extract part of filename, for eg: File="010020004_S-TOR-Sort-CASAP_20170519_121504_0007.TXT" here i need first 5 words of file i.e. FilePart="$(echo "${File%"${File#******}"}")" Echo $FilePart 010020004_S-TOR-Sort-CASAP But what if i get filename like below: ... (3 Replies)
Discussion started by: gnnsprapa
3 Replies

4. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

5. Shell Programming and Scripting

SUBSEP Seperator problem with awk

The following code removes new line with in double quotes I am replacing newline character with in double quotes with 123. intermediatenewline_remover () { typeset Infile=$1 nawk -F"," '{ record = record $0 if ( gsub( /"/, "&", record ) % 2 ) { record = record "123" ... (3 Replies)
Discussion started by: pinnacle
3 Replies

6. Shell Programming and Scripting

Handling Unit Seperator Delimeter

Hi, We have a file with a unit seperator as the delimeter. Here are the Sample lines from the file: ASIA/PACIFICHong KongFX2007071080900 ASIA/PACIFICHong KongFX2007071080900/ 800129HK This delimeter has the ascii value of \037. I have to... (4 Replies)
Discussion started by: sviswana
4 Replies

7. Shell Programming and Scripting

How to change field seperator

Hi Please help me out with this problem: I want to have a script that would change the nth field seperator in a line into something else. like a,d,4,2,97,8,9 into a,d,4,2,97/8/9 Thanks (2 Replies)
Discussion started by: onthetopo
2 Replies

8. UNIX for Dummies Questions & Answers

Using | as a seperator in join

I need to use | as a seperator in unix join command. i tried changing seperator using -t option but iit is not working. can u please help. (5 Replies)
Discussion started by: firvin
5 Replies

9. Shell Programming and Scripting

Comma seperator

I am trying to create a new CSV file from an existing CSV file whose content is as follows: "1","Tom,Garry","111" "2","Tom,Garry","222" when i use Cat file | cut -d',' -f1,3 or awk to have only the 1st and 3rd column in my new CSV file, instead of creating a file content as "1","111"... (6 Replies)
Discussion started by: premar
6 Replies

10. Shell Programming and Scripting

Awk Field Seperator Help

I wrote a script on HPUX 11.11 to turn a Decimal subnet mask (255.255.254.0) to hex 0xfffffe00 (subset of a bigger script). It works great on the HPUX systems but on the freebsd box the awk is not seperating the fields properly. I tried to google for a solution and seaching these forums i am just... (3 Replies)
Discussion started by: insania
3 Replies
Login or Register to Ask a Question