- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script query
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 09:26 PM
11-10-2005 09:26 PM
while read SURNAME FIRSTNAME
do
typeset -l SNAME=$SURNAME | cut -c1-5
while [ ${#SNAME} -lt 5 ]
do
SNAME=$SNAME"a"
done
typeset -l FNAME=$FIRSTNAME | cut -c1
UNAME=`echo $SNAME$FNAME`
do
echo $UNAME
done
done < file1.txt
Basically from a list of names I am trying to create a list of Unames (first 5 characters of surname and first initial - "a" is used as padding if surname is less than 5 characters). I am using file1.txt for this. A sh -xvf shows the following:
while read SURNAME FIRSTNAME
do
typeset -l SNAME=$SURNAME | cut -c1-5
while [ ${#SNAME} -lt 5 ]
do
SNAME=$SNAME"a"
done
typeset -l FNAME=$FIRSTNAME | cut -c1
UNAME=`echo $SNAME$FNAME`
do
createuname.sh: Syntax error at line 14 : `do' is not expected.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 09:30 PM
11-10-2005 09:30 PM
Re: script query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 09:32 PM
11-10-2005 09:32 PM
Re: script query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 09:35 PM
11-10-2005 09:35 PM
Re: script query
UNAME=`echo $SNAME$FNAME`
do
echo $UNAME
done
done < file1.txt
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 09:35 PM
11-10-2005 09:35 PM
Re: script query
UNAME=`echo $SNAME$FNAME`
do
echo $UNAME
done
done < file1.txt
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 09:36 PM
11-10-2005 09:36 PM
Re: script query
Try as,
while read SURNAME FIRSTNAME
do
typeset -l SNAME=$SURNAME | cut -c1-5
while [ ${#SNAME} -lt 5 ]
do
SNAME=$SNAME"a"
done
typeset -l FNAME=$FIRSTNAME | cut -c1
UNAME=`echo $SNAME$FNAME`
echo $UNAME
done < file1.txt
It will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 09:40 PM
11-10-2005 09:40 PM
Re: script query
Try this:
while read SURNAME FIRSTNAME
do
typeset -l SNAME=$(echo $SURNAME | cut -c1-5)
if [ ${#SNAME} -lt 5 ]
then
SNAME=$SNAME"a"
fi
typeset -l FNAME=$(echo $FIRSTNAME | cut -c1)
UNAME=`echo "$SNAME$FNAME"`
echo $UNAME
done < file1.txt
It will work.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 10:47 PM
11-10-2005 10:47 PM
Re: script query
+ read SURNAME FIRSTNAME
+ cut -c1-5
+ echoAncliff
createuname.sh[3]: echoAncliff: not found.
+ typeset -l SNAME=
+ [ 0 -lt 5 ]
+ SNAME=a
+ cut -c1
+ typeset -l FNAME=Gillian
+ + echo a
UNAME=a
+ echo a
a
+ read SURNAME FIRSTNAME
+ cut -c1-5
+ echoAnderson
createuname.sh[3]: echoAnderson: not found.
+ typeset -l SNAME=
+ [ 0 -lt 5 ]
+ SNAME=a
+ cut -c1
+ typeset -l FNAME=Jean
+ + echo a
UNAME=a
+ echo a
a
+ read SURNAME FIRSTNAME
+ cut -c1-5
+ echoAnderson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 11:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2005 11:57 PM
11-10-2005 11:57 PM
Re: script query
I am now getting the first five letters of their surname (all in lowercase as required) but their first initial is not being appended ie i am getting an output of adams rather then adamsc etc.
Any suggestions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2005 12:08 AM
11-11-2005 12:08 AM
Re: script query
$perl -pe '($s,$f)=split; $_=substr(lc($s)."aaaa",0,5) . substr($f,0,1) . "\n"' x.txt
---gives---
aapjen
miesjt
vuuraz
jetjek
--- from x.txt ----
aapjes noot
MIEsje teun
vuur zus
jetje kees
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2005 12:34 AM
11-11-2005 12:34 AM
Re: script query
Muthukumar's code works allright on my system, e.g. if the content of file1 is
Gill Ravinder
the script outputs
gillar
check variable spelling...
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2005 12:51 AM
11-11-2005 12:51 AM
Re: script query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2005 01:19 AM
11-11-2005 01:19 AM
Re: script query
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2005 01:19 AM
11-11-2005 01:19 AM