Solved

help using awk

Posted on 2011-03-07
2
262 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

912 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

17 Experts available now in Live!

Get 1:1 Help Now