Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > command line text processing..

Reply
Thread Tools

command line text processing..

 
 
Jim Carter
Guest
Posts: n/a
 
      11-10-2003
Hi all,

I am on Windows:

I have a customozed command "lsdesktops" (I mean when I run C:\>
lsdesktops at cmd prompt) and it gives an output like below:
--------------------------------------
TEST-MACHINE1:Windows SP3 Memory
TEST-MACHINE2:Windows SP1 Processor
TEST-MACHINE3:Windows SP4 Configuration
......... ###and many more lines like the above three lines
---------------------------------------

Now I need a commmand line perl code to strip off every thing that
starts after colon (inlcuding colon).
Ex: The output should be

-------------------
TEST-MACHINE1
TEST-MACHINE2
TEST-MACHINE3
TEST-MACHINE4
TEST-MACHINE5
TEST-MACHINE6
......
......
---------------------


I know I need to use -e option and reg expression, but is not giving
me the exact result.

Thanks,
JCarter
 
Reply With Quote
 
 
 
 
Kien Ha
Guest
Posts: n/a
 
      11-10-2003
Jim Carter wrote:
> Hi all,
>
> I am on Windows:
>
> I have a customozed command "lsdesktops" (I mean when I run C:\>
> lsdesktops at cmd prompt) and it gives an output like below:
> --------------------------------------
> TEST-MACHINE1:Windows SP3 Memory
> TEST-MACHINE2:Windows SP1 Processor
> TEST-MACHINE3:Windows SP4 Configuration
> ........ ###and many more lines like the above three lines
> ---------------------------------------
>
> Now I need a commmand line perl code to strip off every thing that
> starts after colon (inlcuding colon).
> Ex: The output should be
>
> -------------------
> TEST-MACHINE1
> TEST-MACHINE2
> TEST-MACHINE3
> TEST-MACHINE4
> TEST-MACHINE5
> TEST-MACHINE6
> .....
> .....
> ---------------------
>
>
> I know I need to use -e option and reg expression, but is not giving
> me the exact result.
>


Show us your code so we know what it did right/wrong.

lsdesktops | perl -F: -lane "print $F[0]"



 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      11-10-2003
Jim Carter <(E-Mail Removed)> wrote:

> I need a commmand line perl code to strip off every thing that
> starts after colon



perl -pe 's/:.*//s'


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse Location to Text line or Text line to location kuna.subramaniyam@gmail.com Javascript 2 04-14-2008 01:46 PM
How to read a text file line by line and remove some line kaushikshome C++ 4 09-10-2006 10:12 PM
Error in asp text: Command text not set for the command Jack ASP General 2 03-07-2005 11:27 PM
Need simple command for validating xml files at the command line Bernd Oninger XML 1 07-07-2004 06:20 PM
RUN/execute a Command-Line command from an ASP page. Lucas Cowald ASP .Net 4 10-23-2003 11:09 AM



Advertisments