?
Solved

help using awk

Posted on 2011-03-07
2
Medium Priority
?
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Maciej S earned 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 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