Solved

I need a regular expression

Posted on 2004-04-30
2
235 Views
Last Modified: 2010-04-21
Hi!

i've got this line stored in a perl variable named $size:

4       /mail/lalalala.net/wbiz100332-m92

I want to keep only first number, this number can have from 1 to 4 digits (it's size in Kb)... what regular expressions can i use for this?

Thanks in advance!
0
Comment
Question by:morsa801tons
2 Comments
 
LVL 6

Expert Comment

by:bira
ID: 10959540
echo $size |cut -c1-4
0
 
LVL 14

Accepted Solution

by:
chris_calabrese earned 125 total points
ID: 10960114
$size ~= /^(\d+) /;
my $fubar = $1;

or

$size ~= s/ .*//;
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

Suggested Solutions

Title # Comments Views Activity
AIX Server 10 79
EMC VNX  storage pool  Vs  raid group  question 3 120
How to find files recursively in ftp server quickly? 7 101
check unix curl command return value 7 84
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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 shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

920 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

15 Experts available now in Live!

Get 1:1 Help Now