Computing.Net > Forums > Unix > Help withCut Command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Help withCut Command

Reply to Message Icon

Name: MyCovina
Date: February 5, 2008 at 10:57:24 Pacific
OS: AIX
CPU/Ram: 500
Product: AIX
Comment:

X=' "xyz@hotmail.com" "N" "DEVL" "SCOTT" "Western" "Elementary" "West Haven Elementary" "First Grade"'

emailid="$(print $X|cut -f1 -d\ | cut -f2 -d\" |cut -f1 -d\" )"
send_mail="$(print $X|cut -f2 -d\ | cut -f2 -d\" |cut -f1 -d\" )"
sid="$(print $X|cut -f3 -d\ | cut -f2 -d\" |cut -f1 -d\" )"
user="$(print $X|cut -f4 -d\ | cut -f2 -d\" |cut -f1 -d\" )"
region="$(print $X|cut -f5 -d\ | cut -f2 -d\" |cut -f1 -d\" )"
typ="$(print $X|cut -f6 -d\ | cut -f2 -d\" |cut -f1 -d\" )"
org="$(print $X|cut -f7 -d\ | cut -f2 -d\" |cut -f1 -d\" )"
asgn="$(print $X|cut -f8 -d\ | cut -f2 -d\" |cut -f1 -d\" )"

echo $org
returns West
echo $asgn
return Haven
I need to org to return West Haven Elementary and asgn to return First Grade

TIA
Covina



Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: February 5, 2008 at 13:19:31 Pacific
Reply:

A shell subroutine would process the passed parameters properly.


# !/bin/bash

assign_vars() {
emailid=$1
send_mail=$2
sid=$3
user=$4
region=$5
typ=$6
org=$7
asgn=$8
}

X='"xyz@hotmail.com" "N" "DEVL" "SCOTT" "Western" "Elementary" "West Haven Elementary" "First Grade"'

eval assign_vars $X

echo "emailid=$emailid"
echo "send_mail=$send_mail"
echo "sid=$sid"
echo "user=$user"
echo "region=$region"
echo "typ=$typ"
echo "org=$org"
echo "asgn=$asgn"


./myscript.sh
emailid=xyz@hotmail.com
send_mail=N
sid=DEVL
user=SCOTT
region=Western
typ=Elementary
org=West Haven Elementary
asgn=First Grade


0

Response Number 2
Name: MyCovina
Date: February 6, 2008 at 09:47:52 Pacific
Reply:

Thanks for your help. It works great

TIA
Covina


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Help withCut Command

Creating Tags in Unix www.computing.net/answers/unix/creating-tags-in-unix/6186.html

How to use substr function in sh www.computing.net/answers/unix/how-to-use-substr-function-in-sh/6654.html

unix command help www.computing.net/answers/unix/unix-command-help/6321.html