Solved

help using awk

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
2 Powershell scripts don't seem able to capture data on all machines 4 85
RoboCopy to Changing External Drives 2 60
FTP Script 25 66
AWK: Pythagoras script 6 37
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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…

733 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