Solved

help using awk

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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