Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

sed command

Original Message
Name: totototo
Date: March 25, 2008 at 12:56:03 Pacific
Subject: sed command
OS: xp
CPU/Ram: 4GO
Model/Manufacturer: windows
Comment:
Hello,
i am using sed (gnused for windows)with a batch file. I would like to extract from a text file the following informations: 1,2,3 (second column)
A 3
B 3
C 1
C 2
C 3
I have done a code which gives a list instead of a summary of the data inside the list:
3
3
1
2
3
How can i have only the "one number" (1,2,3)?
my command is:
sed -n "s/[A-Z]*//w Post_temp_list.txt" s_post.txt

Report Offensive Message For Removal


Response Number 1
Name: ghostdog
Date: March 25, 2008 at 17:32:50 Pacific
Subject: sed command
Reply: (edit)
use the right tool for the job. sed is not really suited for this type of "column based" problem.
You can use gawk instead. Download and install gawk from here: http://gnuwin32.sourceforge.net/pac...

the code:


{
a[$2]
}
END{
printf "("
for ( i in a) printf "%s," , i
print ")"
}

save as script.awk and from command line


c:\test> gawk -f script.awk inputfile


Report Offensive Follow Up For Removal

Response Number 2
Name: user57
Date: March 27, 2008 at 08:45:01 Pacific
Subject: sed command
Reply: (edit)
sed 's/[A-Z]//g' testfile

Report Offensive Follow Up For Removal

Response Number 3
Name: totototo
Date: March 28, 2008 at 02:36:01 Pacific
Subject: sed command
Reply: (edit)
Thank you all for your help,
ghostdog gave me an excellent script which work very well. I have to learn awk now!

Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: sed command

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs

Best WinMo phone of 2008


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC