Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How do I get the fields after a string Post 11200 by Perderabo on Friday 30th of November 2001 10:13:55 AM
Old 11-30-2001
Code:
#! /usr/bin/ksh
SEARCH=$1

OSTRING="A, B, C, D, E, F, G, H"
STRING=$(echo $OSTRING | sed s/,//g)
set $STRING

integer found
found=0

while (($# && found<3)) ; do
        if ((!found)) ; then
                [[ $1 = $SEARCH ]] && found=1
        else
                RESULT[found]=$1
                ((found=found+1))
        fi
        shift
done

case $found in
0)      echo $SEARCH not found
        ;;
1)      echo $SEARCH was last item in $OSTRING
        ;;
2)      echo $SEARCH was followed only by ${RESULT[1]}
        ;;
3)      echo ${RESULT[1]}, ${RESULT[2]}
        ;;
esac

exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

2. Shell Programming and Scripting

script to sort a string of numerical data in set fields

So, I will be working with someone and basically we are trying to build a form that is submitted most likely via the web and the data is just a string of numbers. like: 19383882872201110929282821818182827349190102837364718191001932873711 Now, each number is part of a numerical value of... (4 Replies)
Discussion started by: tlarkin
4 Replies

3. Shell Programming and Scripting

AWK break string into fields + pattern match

I am trying to break a string into separate fields and print the field that matches a pattern. I am using awk at the moment and have gotten this far: awk '{for(i=1;i<=NF;++i)print "\t" $i}' longstring This breaks the string into fields and prints each field on a separate line. I want to add... (2 Replies)
Discussion started by: Moxy
2 Replies

4. Shell Programming and Scripting

mappin strings of two different file and finding the mapped string and then map other fields.

As i am new to unix so facing some problems in scripting: here is my question: i m having two files. 1st file say a.txt contain 3 column like SPECIALITY|UMP_CODE|SPECIALTY_CODE Addictive Diseases|25ADD|ADD Addictive Diseases/Family Practice|25ADD|ADD/FP Aerospace Medicine|1.041666667|AM... (4 Replies)
Discussion started by: dsh007
4 Replies

5. Shell Programming and Scripting

How to read a delimited string and assign fields to incremented variables?

How can I read a string delimited on spaces and assign the fields to incremented variables. For example: Given $exts= txt dat mov I want to read in $exts and have "txt" "dat" and "mov" assigned to incremented variables like $ext1, $ext2, etc. I would like to do this in a loop so that I can... (4 Replies)
Discussion started by: runit
4 Replies

6. Shell Programming and Scripting

Identifying entries based on 2 fields in a string.

Hi Guys, I’m struggling to use two fields to do a duplicate/ unique by output. I want to look IP addresses assigned to more than one account during a given period in the logs. So duplicate IP and account > 1 then print all the logs for that IP. I have been Using AWK (just as its installed... (3 Replies)
Discussion started by: wabbit02
3 Replies

7. Shell Programming and Scripting

Need a separator string between fields in cut -c command

Hi All, I'm trying to view data using cut command for a fixed length file using the below command: cut -c 1-3,4-5 FALCON_PIS_00000000.dat I want to mention a separator say | (pipe) in between 1-3 and 4-5. Please let me know how to achieve this. Thanks in Advance, (3 Replies)
Discussion started by: HemaV
3 Replies

8. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

9. Shell Programming and Scripting

awk partial string match and add specific fields

Trying to combine strings that are a partial match to another in $1 (usually below it). If a match is found than the $2 value is added to the $2 value of the match and the $3 value is added to the $3 value of the match. I am not sure how to do this and need some expert help. Thank you :). file ... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Beginners Questions & Answers

Is there a UNIX command that can compare fields of files with differing number of fields?

Hi, Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account. $ head -500 x.txt y.txt ==> x.txt <== TEST01 APP_USER_PROFILE USER03 APP_USER_PROFILE TEST02 APP_USER_EXP_PROFILE TEST04 APP_USER_PROFILE USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
OFXCONNECT(1)							   User Commands						     OFXCONNECT(1)

NAME
ofxconnect - Create a statement request file SYNOPSIS
ofxconnect [OPTIONS]... [FILES]... DESCRIPTION
ofxconnect 0.9.4 prints to stdout the created OFX file based on the options you pass it. currently it will only create a statement request file. you can POST this to an OFX server to request a statement from that financial institution for that account. -h, --help Print help and exit -V, --version Print version and exit --fipid=STRING FI partner identifier (looks up fid, org & url from partner server) --fid=STRING FI identifier --org=STRING FI org tag --bank=STRING IBAN bank identifier --broker=STRING Broker identifier --user=STRING User name --pass=STRING Password --acct=STRING Account ID --type=INT Account Type 1=checking 2=invest 3=ccard --past=LONG How far back to look from today (in days) --url=STRING Url to POST the data to (otherwise goes to stdout) --trid=INT Transaction id Group: command -s, --statement-req Request for a statement -a, --accountinfo-req Request for a list of accounts -p, --payment-req Request to make a payment -i, --paymentinquiry-req Request to inquire about the status of a payment -b, --bank-list List all known banks -f, --bank-fipid List all fipids for a given bank -v, --bank-services List supported services for a given fipid --allsupport List all banks which support online banking ofxconnect 0.9.4 May 2012 OFXCONNECT(1)
All times are GMT -4. The time now is 01:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy