Solved

help using awk

Posted on 2011-03-07
2
255 Views
Last Modified: 2012-08-14
Below is the linux command i use to get user quota
$ sudo -u lospsr quota | tail -n1
                1045124* 200000 3000000   6days      45       0       0

and below command i will use to know when the user exceeded the quota
$ sudo -u lospsr quota | tail -n1 | awk '{print $1}'
1045124*
$

please provide me the command where i want only number(means the awk should be able to cut the "*"), i don't want "*" at the end of the number in the output, because my other script that uses this command doens't understand "*"

0
Comment
Question by:wasman
2 Comments
 
LVL 23

Accepted Solution

by:
Maciej S earned 500 total points
ID: 35059257
Few possibilities:
1. sudo -u lospsr quota | tail -n1 | awk '{print gensub(/*/, "", "", $1)}'
2. sudo -u lospsr quota | awk '/[0-9]day|EXPIRED/ {print gensub(/*/, "", "", $1)}'
3. sudo -u lospsr quota | tail -n1 | awk '{print $1}' | tr -d "*"
4. sudo -u lospsr quota | sed '$!d;s/\s*\([0-9]\+\).*/\1/'

And a lot more possibilities :)
0
 

Author Closing Comment

by:wasman
ID: 35059439
That worked, Thanks a lot oklit
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video discusses moving either the default database or any database to a new volume.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now