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
09-29-2003 08:56 AM
09-29-2003 08:56 AM
awk help
do
USER=`echo $i | awk -F":" '{print $1}'`
UID=`echo $i | awk -F":" '{print $2}'`
GROUP=`echo $i | awk -F":" '{print $3}'`
DIR=`echo $i | awk -F":" '{print $4}'`
SHELL=`echo $i | awk -F":" '{print $5}'`
COMMENTS=`echo $i | awk -F":" '{print $6}'`
done
The sample of the line in t/mp/users.dat is following:
user:uid:group:dir:shell:firstname lastname,location,phone,
My question is: how can I assign the rest portion of the line
after"shell:" to $6?
The current script only assign "firstname" to $6, and it cuts off the portion of
" lastname,location,phone,".
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2003 09:06 AM
09-29-2003 09:06 AM
Re: awk help
no points
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2003 09:10 AM
09-29-2003 09:10 AM
Re: awk help
oldIFS="$IFS"
IFS=":"
cat /tmp/users.dat |
while read USER UID GROUP DIR SHELL REST
do
print $USER
print $REST
#etc
done
IFS="$oldIFS"
sorry for the test, but I hadn't been able to reply for a month or so
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2003 09:16 AM
09-29-2003 09:16 AM
Re: awk help
only works if ":" is only used as field seperator
cat tmp/users.dat | tr ":" " " |
read USER UID GROUP DIR SHELL COMMENTS
print $USER
print "$COMMENTS"
if there are extra fields read will place them all in the last variable name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2003 09:18 AM
09-29-2003 09:18 AM
Re: awk help
cat tmp/users.dat | tr ":" " " |
while read USER UID GROUP DIR SHELL COMMENTS
do
print $USER
print "$COMMENTS"
# etc
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2003 09:22 AM
09-29-2003 09:22 AM
Re: awk help
#!/usr/bin/sh
FNAME=/tmp/users.dat
cat ${FNAME} | while read i
do
USER=$(echo ${i} | awk -F":" '{print $1}')
UID=$(echo ${i} | awk -F":" '{print $2}')
GROUP=$(echo ${i} | awk -F":" '{print $3}')
DIR=$(echo ${i} | awk -F":" '{print $4}')
SHELL=$(echo ${i} | awk -F":" '{print $5}')
COMMENTS=$(echo ${i} | awk -F":" '{print $6}')
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2003 09:24 AM
09-29-2003 09:24 AM
Re: awk help
COMMENTS=`echo $i | cut -d":" -f6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2003 09:29 AM
09-29-2003 09:29 AM
Re: awk help
cat /tmp/users.dat |
while read line
do
comment=${line##*:}
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 05:43 AM
10-01-2003 05:43 AM
Re: awk help
Thanks for your messages,
Could you please explore this a little bit more:
comment=${line##*:}
Points will be followed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 05:54 AM
10-01-2003 05:54 AM