- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell program problem!
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
08-30-2002 04:58 AM
08-30-2002 04:58 AM
username sn salary
========= == ======
acduser0001 1 1355
acduser0002 2 1570
...
isduser0001 1 1669
isduser0002 2 1398
...
psduser0001 1 1688
psduser0002 2 1568
...
I want to make that all users whose username begin with "isduser", its salary increase 1000.
How to do?
Thanks a lot!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2002 05:09 AM
08-30-2002 05:09 AM
Solutionhere is a quick and dirty awk hack, use with care:awk 'match($1,"^isduser") { printf "%s %d %d\n",$1,$2,$3+1000;a=1}
a==0 {print $0}
{a=0}'
You my move the newfile over the origfile
mv
mv
Heiner
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2002 05:10 AM
08-30-2002 05:10 AM
Re: Shell program problem!
{
if(substr($1,1,7)=="isduser")
{ salary=$3 + 1000;
print $1,$2,salary;
} else print $0;
}' yourfile > yournewfile
Jean-Luc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2002 05:12 AM
08-30-2002 05:12 AM
Re: Shell program problem!
awk ' { $1 ~ /^isduser/ { if ($3 >= 1000) ; print $1 $3 }}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2002 05:14 AM
08-30-2002 05:14 AM
Re: Shell program problem!
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2002 05:14 AM
08-30-2002 05:14 AM
Re: Shell program problem!
username sn salary
========= == ======
acduser0001 1 1355
acduser0002 2 1570
...
isduser0001 1 1669
isduser0002 2 1398
...
psduser0001 1 1688
psduser0002 2 1568
l1:/u/usr/merijn 108 > perl -pi -e'/^isduser/&&s/\b(\d+)$/$1+1000/e' sal_file
l1:/u/usr/merijn 109 > cat sal_file
username sn salary
========= == ======
acduser0001 1 1355
acduser0002 2 1570
...
isduser0001 1 2669
isduser0002 2 2398
...
psduser0001 1 1688
psduser0002 2 1568
l1:/u/usr/merijn 110 >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2002 05:23 AM
08-30-2002 05:23 AM
Re: Shell program problem!
change my {salary=salary*1.10} to {salary=salary+1000}
as in
cat dah4 | awk '{salary=$3; if ( /^isduser/ ) {salary=salary + 1000}; printf("%s %s %s\n", $1, $2, salary);}'
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2002 05:38 AM
08-30-2002 05:38 AM
Re: Shell program problem!
Sorry
I misunderstod you, this should work better.
awk ' $1 ~ /^isduser/ { if ($3 >= 1000) ; print $1" "$2" " $3+1000 }
$1 !~ /^isduser/ { print $0 } '