command line text processing..

J

Jim Carter

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
 
K

Kien Ha

Jim said:
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]"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top