Re: question: text substitution using Perl

2006-10-23 Thread Zhao Peng

Dear Kevin,

Thanks a lot for your help. I have 3 derived questions from your script.

Question 1:
For the back references, you used ${1} for the 1st captured buffer, 
while some books/people simply use $1, I'm wondering if you use {} as an 
extra caution to make sure it refers to the 1st captured buffer in case 
there are some digits followed.



Question 2:
line 1   perl -i.bak \
line 2-pe 's/ \$(\d+)\. / \$ebcdic${1}. /g;
line 3 s/ (\d+)\. / s370ff${1}. /g;' \
line 4your-directory-somewhere/*readme*

On the end of line 1 and 3, you have a back slash. Is it for separating 
input to separated lines for better readability? If so, why is there no 
back slash on the end of line 2?



Question 3:
You used a period . after ${1}, wouldn't it be safe to use \. as the 
original string only ends with a period and we don't want to change it? 
I think . can match any single character except a newline.



Thank you for your time.

Zhao

Kevin D. Clark wrote:

Zhao Peng writes:


substitution 1
The characteristic of original string:
1, always start with $
2, then followed by an integer, could be more than 1 digit, such as 23
3, always end with a period .
4, there is always a blank before  after original string
For example: $2.

The characteristic of target string: always has ebcdic inserted into
the original string between $ and the integer
For example: $ebcdic2.

So the substitution will look like this
$2.  -  $ebcdic2.
$67.  -  $ebcdic67.

Should the regular expression for original string be: \$\d+\.   ?


Looks pretty much right to me.

I would make this replacement like this:
 
  s/ \$(\d+)\. / \$ebcdic${1}. /g;


The ${1} in there is something called a backreference.

The 'g' at the end of the line generally specifies do this as many
times as possible on each line.



substitution 2
The characteristic of original string:
1, always start with an integer, could be more than 1 digit, such as 23
2, then end with a period .
3, there is always a blank before  after original string
For example: 2.

The characteristic of target string:
always has s370ff added to the beginning of original string
For example: s370ff2.

So the substitution will look like this

2.  -  s370ff2.
14.  -  s370ff14.

Should the regular expression for original string be: \d+\.   ?


I would make this replacement like this:
 
  s/ (\d+)\. / s370ff${1}. /g;




My real situation is that I have a bunch of files at one directory, of
which for the files whose name contained readme,  I need to do 2
substitutions described above.


One way to quickly do this might be like this:

  perl -i.bak \
   -pe 's/ \$(\d+)\. / \$ebcdic${1}. /g;
s/ (\d+)\. / s370ff${1}. /g;' \
   your-directory-somewhere/*readme*


This in itself makes a backup for you, but you might want to make your
own backup files beforehand.

Just another Perl hacker,

--kevin

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


Re: question: text substitution using Perl

2006-10-23 Thread Zhao Peng

Mike and Kevin,

Thank you both for quick, detailed, and crystal clarification and 
explanation.


Just one more question:

To the shell, anything inside of single quotes is a single argument, so 
all of the spaces, newlines, etc. in there are passed without shell 
interpretation (quoted from the Mike's answer to my 2nd question).


Can this claim also be extended for double quotes?

Thanks,
Zhao

mike ledoux wrote:


The backslash on line 3 is interpreted by the shell as a line
continuation, so yes, it is just for increased readability by
letting you break a long command line over multiple lines.  It is
not needed at the end of line 2 because the end of line 2 is inside
of single quotes.  To the shell, anything inside of single quotes is
a single argument, so all of the spaces, newlines, etc. in there are
passed without shell interpretation.


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


question: text substitution using Perl

2006-10-20 Thread Zhao Peng

Hi,

Being a slow Perl learner who hasn't make much progress, I'm wondering 
if some kind souls could help me achieve the following 2 text 
substitution tasks detailed below.


substitution 1
The characteristic of original string:
1, always start with $
2, then followed by an integer, could be more than 1 digit, such as 23
3, always end with a period .
4, there is always a blank before  after original string
For example: $2.

The characteristic of target string: always has ebcdic inserted into 
the original string between $ and the integer

For example: $ebcdic2.

So the substitution will look like this
$2.  -  $ebcdic2.
$67.  -  $ebcdic67.

Should the regular expression for original string be: \$\d+\.   ?

substitution 2
The characteristic of original string:
1, always start with an integer, could be more than 1 digit, such as 23
2, then end with a period .
3, there is always a blank before  after original string
For example: 2.

The characteristic of target string:
always has s370ff added to the beginning of original string
For example: s370ff2.

So the substitution will look like this

2.  -  s370ff2.
14.  -  s370ff14.

Should the regular expression for original string be: \d+\.   ?

My real situation is that I have a bunch of files at one directory, of 
which for the files whose name contained readme,  I need to do 2 
substitutions described above.


Any input (and your time) is greatly appreciated.

Thanks,
Zhao

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/


file size estimation

2006-09-15 Thread Zhao Peng

Hi,

Suppose a EBCDIC file on a tape from IBM mainframe is read onto a Linux 
server, and this EBCDIC file on the tape has 100 records with a length 
of 13054, is it correct to estimate the size of the file on Linux server 
would be 1,305,400 bytes? Is block size information also needed to 
calculate the size?


Please correct me if these terms are used incorrectly, also hopefully 
this question is not too OT.


Thanks,
Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


free notebook memory (256 MB)

2006-05-18 Thread Zhao Peng

Hi,

I'm giving it away for free since I upgraded to 1 GB version, and don't 
have a spare slot for it .


200-Pin SO-DIMM notebook memory: Capacity is 256 MB,  speed is DDR 266 
(PC 2100)


Drop me a line if anyone wants it. (I live in Norwich and work in Hanover)

Thanks,
Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


[FIXED]: remove linux, and then install Windows XP

2006-04-27 Thread Zhao Peng

Hi,

It turned out the culprit of my booting problem is nothing but a 
non-functional Windows XP installer CD, which is suspected by some kind 
souls here.


With a working XP CD, no problem whatsoever in terms of booting into XP 
installation mode.


Before I found out XP CD is what to be blamed, I did both of following:

First, dd if=/dev/zero of=/dev/hda bs=512 count=1 when booted into 
Fedora rescue mode.


After this, the system didn't show missing operating system message 
whenever the machine was restarted.


Then, I did fdisk /mbr when booted from floppy.

But after this, the system did show missing operating system whenever 
the machine was restarted.


Isn't is true that fdisk /mbr and dd if=/dev/zero of=/dev/hda bs=512 
count=1 are supposed to achieve same purpose?


If that's the case, why did they seem to have different consequence in 
terms of the message generated?


So now I'm back to the same old Windows. Next step I plan to install 
Fedora or Ubuntu, depending on which can enable me to use USB device. (I 
know they both are supposed to be able to automatically support USB device)


One more observation:

Now whenever the system boots up, there is always 2 lines of message:

unknown flash type
boot from CD:

What does  unknown flash type refer to?

Thank you for all your helpful solutions.

Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


CLARIFICATION: Re: remove linux, and then install Windows XP

2006-04-26 Thread Zhao Peng

Hi,

First I wanted to thank you all for your help. The list is so great.

When I said Then I put in Windows XP installation CD and restarted 
computer in my original post, I really meant that I booted the machine 
from Windows XP installation CD.


The CD/DVD drive is the 1st bootable drive. I double checked and 
verified it in BIOS setting.


So my problem, at this point, is that I can't boot into Windows 
installation process, with that the CD drive set as the first bootable 
drive and the Windows XP installation CD is there.


BUT, if I put into Fedora Core 5 installation DVD in the CD/DVD drive, 
the machine can get into Fedora installation mode.


Please let me know if my description is not clear enough.

P.S.

Whenever I put Fedora Core 5 DVD in the CD/DVD drive, the machine always 
boot into Fedora installation mode, which I believe, means that The 
CD/DVD drive is 1st bootable drive. (well, could it be possible that 
Hard drive is the 1st bootable drive but can't boot from it?), Correct 
me if I'm wrong, please.


Thank you again.

BTW, Chris, I've NOT yet got Windows installed.

Chris Linstid wrote:
I could be wrong, but I think he already got Windows reinstalled, but 
he still has grub installed in the MBR and grub is looking for his 
/boot partition (which he already blew away)... thus the grub error.


- Chris


On Apr 26, 2006, at 10:34 AM, Neil Schelly wrote:

It seems you're getting a lot of help with the MBR, but that isn't 
what you're
looking for.  You have/had Linux on there and want to install Windows 
over it

instead.

As far as I know, you just have to boot from the Windows install disc 
and it
will be more than happy to just take over the hard disk regardless of 
whether

or not your MBR or partition tables are clear.

In your case, you said that instead of booting from the Windows 
installer

disc, you saw a GRUB message instead of the Windows bootup.  That would
indicate to me that your BIOS is set to boot from the hard disk 
before the

CD-ROM.

So clearing your MBR will probably make the BIOS try and boot from 
the hard
disk, fail, and then boot from the CD-ROM.  But you may find it a 
whole lot

easier to tell your BIOS to look to the CD-ROM first.
-N
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss





___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: remove linux, and then install Windows XP

2006-04-26 Thread Zhao Peng

Tom,

How can I find an correct number to put into count=?

Thanks,
Zhao

Tom Buskey wrote:

3) I think on the linux rescue you can also do something like:

dd if=/dev/zero of=/dev/hda bs=2048 count=1

You may have to up the count.

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: CLARIFICATION: Re: remove linux, and then install Windows XP

2006-04-26 Thread Zhao Peng

Neil,

That's a good suggestion, Thank you.

I will try Windows installer disc on another machine when I get home 
tonight to see if it's in fact a good disc.


Zhao

Neil Schelly wrote:
That would seem to indicate to me then that there's a problem with your 
Windows CD.  Because GRUB was installed on your hard disk, it's still there 
(until Windows wipes it).  But since you're seeing it with the Windows disc 
in the drive, that suggests your BIOS is giving up on finding a bootable 
image on that disc and is falling back to the next available boot method, 
your hard disk.


Have you tried that Windows installer disc in another machine to verify that 
it is in fact a good disc?

-N

On Wednesday 26 April 2006 11:13 am, Zhao Peng wrote:
  

Hi,

First I wanted to thank you all for your help. The list is so great.

When I said Then I put in Windows XP installation CD and restarted
computer in my original post, I really meant that I booted the machine
from Windows XP installation CD.

The CD/DVD drive is the 1st bootable drive. I double checked and
verified it in BIOS setting.

So my problem, at this point, is that I can't boot into Windows
installation process, with that the CD drive set as the first bootable
drive and the Windows XP installation CD is there.

BUT, if I put into Fedora Core 5 installation DVD in the CD/DVD drive,
the machine can get into Fedora installation mode.

Please let me know if my description is not clear enough.

P.S.

Whenever I put Fedora Core 5 DVD in the CD/DVD drive, the machine always
boot into Fedora installation mode, which I believe, means that The
CD/DVD drive is 1st bootable drive. (well, could it be possible that
Hard drive is the 1st bootable drive but can't boot from it?), Correct
me if I'm wrong, please.

Thank you again.

BTW, Chris, I've NOT yet got Windows installed.

Chris Linstid wrote:


I could be wrong, but I think he already got Windows reinstalled, but
he still has grub installed in the MBR and grub is looking for his
/boot partition (which he already blew away)... thus the grub error.

- Chris

On Apr 26, 2006, at 10:34 AM, Neil Schelly wrote:
  

It seems you're getting a lot of help with the MBR, but that isn't
what you're
looking for.  You have/had Linux on there and want to install Windows
over it
instead.

As far as I know, you just have to boot from the Windows install disc
and it
will be more than happy to just take over the hard disk regardless of
whether
or not your MBR or partition tables are clear.

In your case, you said that instead of booting from the Windows
installer
disc, you saw a GRUB message instead of the Windows bootup.  That would
indicate to me that your BIOS is set to boot from the hard disk
before the
CD-ROM.

So clearing your MBR will probably make the BIOS try and boot from
the hard
disk, fail, and then boot from the CD-ROM.  But you may find it a
whole lot
easier to tell your BIOS to look to the CD-ROM first.
-N
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss



  


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


remove linux, and then install Windows XP

2006-04-25 Thread Zhao Peng

Hi,

With either Fedora Core 4 or Ubuntu 5.10, none of my USB device 
(flashdrive, usb mouse, usb external harddrive, etc...) works.


So I decided to remove linux then install Windows XP, and then install 
linux to have a dual-boot system.


The 1st link of Google results of install windows linux is on 
Microsoft website:


http://support.microsoft.com/default.aspx?scid=kb;en-us;314458

The article says that I need to use Linux Setup floppy disk to use 
fdisk to delete linux partition.


I am not sure what Linux Setup floppy disk meant, so I googled.

The 2nd link of Google results of Linux Setup floppy disk is on Redhat 
website:


https://www.redhat.com/archives/redhat-list/2005-March/msg00587.html

One of 2 methods the thread suggested is to boot into rescue mode from 
linux installation CD.


So I used  Fedora Core 5 installation DVD and got into rescue mode by F5

Then I followed the steps listed on M$ article mentioned above, and 
deleted all linux partitions.


Then I put in Windows XP installation CD and restarted computer.

Sigh then I ended up with the following error message:

GRUB Loading stage 1.5

GRUB loading, please wait...
Error 22
**
The machine just hang there forever.

One Google answer suggested that I can use fdisk /mbr to wipe the boot 
record clean, but in rescue mode of Fedora Core 5, this (/mbr) seemed an 
invalid option.


Now, what should I do?

I can't help but feel completely pathetic now, which is in part due to 
that I found out I have to assemble the bike I bought online from 
Costco. Gee, why couldn't they just ship me a ready-to-ride bike??? (of 
course this paragraph is apparently off-topic, so I'd better stop here).


Thank you all in advance for the cures.

Zhao
**
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


mouse problem on Redhat Enterprise

2006-04-24 Thread Zhao Peng

Good morning,

I have a switch console (Belkin) which enable me to use only one mouse 
and one keyboard for a windows machine and a linux box.


I'm having a problem with the mouse (ps/2) on linux box (RedHat 
Enterprise). Rehat can recognize it, but I just can't move cursor around 
as I intend to.


This mouse works well on the windows machine.

The same thing described above happened to another working mouse. So my 
feeling is that the problem has nothing to do with the mouse itself.


Any suggestion as to how to make it  work on Redhat?

Thanks
Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


[fixed] mouse problem on Redhat Enterprise

2006-04-24 Thread Zhao Peng

Hi,

I just wanted to let you know that I deleted old mouse setting during 
the boot-up and it then automatically re-configured the mouse setting, 
and now it works.


Thanks,
Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


how to list file and sort by filename using ls

2006-04-24 Thread Zhao Peng

Now I should say good afternoon :)

Using either ls -ul or ls -cl(which are supposed to sort by name 
according to manual, if I understood and used correctly), I just can't 
list files and sort them by filenames.


Google results of key word sort by name linux ls is pretty much the 
same as man ls, not helpful.


OS: Redhat Enterprise.

Any clue? Thanks,

Zhao

P.S.sorry if this sounds UNbelievably naive/stupid. :)
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


how to list file and sort by filename using ls

2006-04-24 Thread Zhao Peng

output of echo $LANG:

   en_US.UTF-8

LANG=C ls -ul does do what I expected to do.

What does C mean? character?

Thank you,  Kevin.

Zhao


1:  can you show us the output of the following:

echo $LANG

2:  Does this do what you want?:

LANG=C ls -ul


I'll bet that the output of ls is sorted, but just not in the order
that you expected.

Regards,


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


list of commands utilities [WAS: change file names]

2006-02-22 Thread Zhao Peng

Hello All,

With the recent change file names experience, I'm wondering if there 
is a simply way to get a comprehensive list of A*L*L available commands 
 utilities on a given linux OS.(Mine is Red Hat Enterprise). If so, how?


If I have the list, I definitely will go through it to see if I could 
find any command/utility which might be helpful for solving my problem, 
before I post any question here.


Thanks a lot!
Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: list of commands utilities [WAS: change file names]

2006-02-22 Thread Zhao Peng

Bruce,

type the tab key twice worked well on my system, thank you!

I have 2 different userid on the system. One has Display all 2430 
possibilities, another one has Display all 2457 possibilities. Why 
are they different? (Because some commands are not available for some 
userid?)


Zhao


Bruce Dawson wrote:

Just list all the files in the directories in the PATH variable - that's
where Unix finds all its commands. You can do this with the following
command:

for dir in `echo $PATH | sed -e 's/:/ /g' ` ; do ls $dir ; done

Note the two different quotes are used ` is the back-tick - usually on
the same key as the ~ charater. And the ' - is the single quote.

Another method, if you're using the 'bash' shell, is to just type the
tab key twice. Note that it'll print more than 1 thousand commands on
the typical Linux system.

- --Bruce
  


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


how to make a computer to function as a router

2006-02-06 Thread Zhao Peng
Hi, all linux experts:I have 2 computers (A  B)A:a desktop (running Fedora Core 4), has 2 ethernet cards. (When I installed Fedora Core 4 on A, I chose server among 4 installation types, and I chose DHCP for both ethernet cards.)
One card is connected to a Motorala cable modem via a Cat5 cable. Another one is an extra one, not used now.(BTW, I'm using Adelphia rhigh speed internet)B:a laptop (running Windows XP professional)
I heard that it's possible to make A a router, so that I connect B to A via a Cat5 cable (not interested in wireless), and then both A and B can get online at the same time My question is:How to re-configure those 2 ethernet cards and do other necessary modification?
Any input/clue is greatly appreciated. Specific step-by-step instruction(if I'm lucky) is extremely welcome! :)Thank you in advance!Zhao


Re: a question about evim

2006-01-25 Thread Zhao Peng
Hi,Thanks for pointing out that the filename~ file is actually the backup file. So I agree with you that it would be safe not to overriding this behavior.Thank you again for prompt reply.
ZhaoOn 1/25/06, Michael Nolin [EMAIL PROTECTED] wrote:
--- Zhao Peng [EMAIL PROTECTED] wrote: Hello, I have a simple question about evim (Easy Vim). Whenever I use evim to edit a file, say 
abc.txt, a same-name file plus ~ is always created. In this case, it will be abc.txt~. It's a bit annoying to me.For gvim its in the Edit pull downSettings menu
set bdir=.,/home/mnolin/tmp,/home/mnolin/backupext file name extension for the backup fileset bex=~backups are usually a good thing so I haven't botheredto override this
behavior. Though I do get swap file already existsmessages.Michael Nolin__Do You Yahoo!?Tired of spam?Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Re: extract string from filename

2006-01-13 Thread Zhao Peng

Kevin,

Thank you very much! I really appreciate it.

I like your find approach, it's simple and easy to understand.

I'll also try to understand your perl approach, when I got time to start 
learning it. (Hopefully it won't be un-fulfilled forever)


I have one more question:

Is it possible to number the extracted string2?

Say, the output file contains the following list of extracted string2:

st
region
local

Any idea about what command to use to number the list  to make it look 
like below:


1 st
2 region
3 local

Again, thank you for your help and time!

Zhao

Kevin D. Clark wrote:

Zhao Peng writes:

  

I'm back, with another extract string question. //grin




find FOLDERNAME -name \*sas7bdat -print | sed 's/.*\///' | cut -d _ -f 2 | sort -u 
 somefile.txt

or

perl -MFile::Find -e 'find(sub{$string2 = (split /_/)[2]; $seen{$string2}++; }, @ARGV); 
map { print $_\n; } keys(%seen)' FOLDERNAME

(which looks more readable as:

  perl -MFile::Find -e 'find(sub{ $string2 = (split /_/)[2];
  $seen{$string2}++;
 }, @ARGV);
  
 map { print $_\n; } keys(%seen)' \

  FOLDERNAME  somefile.txt

)

Either of which solves the problem that you describe.  Actually, they
solve more than the problem that you describe, since it wasn't
apparent to me if you had any subdirectories here, but this is solved too)

(substitute FOLDERNAME with your directory's name)


Honestly, the first solution I present is the way I would have solved
this problem myself.  Very fast this way.

Regards,

--kevin
  


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


extract string from filename

2006-01-12 Thread Zhao Peng

Hi all,

I'm back, with another extract string question. //grin

I have almost 1k small files within one folder. The only pattern of the 
file names is:


string1_string2_string3_string4.sas7bdat

Note:
1, string2 often repeat itself across each file name
For example:
abc_st_nh_num.sas7bdat
abc_st_vt_num.sas7bdat
abc_st_ma_num.sas7bdat
abcd_region_NewEngland_num.sas7bdat
abcd_region_South_num.sas7bdat

2, All 4 strings contain no underscores.
3, 4 strings are separated by  3 underscores (as you can see)
4, The length of all 4 strings are not fixed.

My goal is to :
1, extract string2 from each file name
2, then sort them and keep only unique ones
3, then output them to a .txt file. (one unique string2 per line)

I tried to use cut commands, but can't even figure out how to use the 
filenames as input. Anyone care to offer me a hint?


I also downloaded an e-book called Learning Perl (OReilly, 
4th.Edition), and had a quick look thru its Contents of Table, but did 
not find any chapter which looks likely addressing any issue related to 
my question.


Thank you very much!

Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


extract string

2006-01-10 Thread Zhao Peng

Hi

Suppose that I have a file called abc.txt, which contains the following 
5 lines (columns are delimited by ,)


name,age,school
jerry ,21,univ of Vermont
jesse,28,Dartmouth college
jack,18,univ of Penn
john,20,univ of south Florida

My OS is RedHat Enterprise, how could I extract the string which 
contains univ and create an output file called def.txt, which only has 
3 following lines:


univ of Vermont
univ of Penn
univ of south Florida

Please suggest the simplest command line approach.

Thank you.
Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: extract string

2006-01-10 Thread Zhao Peng

Kenny,

Thank you for your suggestion.

The following line works:
grep univ abc.txt | cut -f3 -d,  dev.txt.


While the following line intended to remove quotes does NOT work:
grep univ abc.txt | cut -f3 -d, | sed s/\//g  dev.txt
It resulted in a line starts with  prompt, and not output dev.txt

Could you please double-check or modify it?

Also, if one column is missing, and , is used to indicate that missing 
column, like the following (2nd column of 3rd line is missing):


name,age,school
jerry ,21,univ of Vermont
jesse,,,Dartmouth college
jack,18,univ of Penn
john,20,univ of south Florida

Does the cut approach still apply? If not, what command would you 
suggest to address this missing issue?


Thank you again.
Zhao


[EMAIL PROTECTED] wrote:

Actually, if you are looking for only lines that contain the string univ, 
then you would want to grep for it:

grep univ abc.txt | cut -f3 -d,  dev.txt.

Paul's example would give you the third field of each line, even if they don't have 
univ in them. Now, if you wanted to remove the quotes, then you would need 
something like:


grep univ abc.txt | cut -f3 -d, | sed s/\//g  dev.txt 


FYI,
Kenny

 -- Original message --
From: Whelan, Paul [EMAIL PROTECTED]
  

Like so: cat abc.txt | cut -d, -f3

Thanks.

-Original Message-
From: Zhao Peng [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 10, 2006 11:51 AM

To: gnhlug-discuss@mail.gnhlug.org
Subject: extract string

Hi

Suppose that I have a file called abc.txt, which contains the following 
5 lines (columns are delimited by ,)


name,age,school
jerry ,21,univ of Vermont
jesse,28,Dartmouth college
jack,18,univ of Penn
john,20,univ of south Florida

My OS is RedHat Enterprise, how could I extract the string which 
contains univ and create an output file called def.txt, which only has


3 following lines:

univ of Vermont
univ of Penn
univ of south Florida

Please suggest the simplest command line approach.

Thank you.
Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss

___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss





  


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: Follow-up: Red Hat / Fedora dual boot

2006-01-10 Thread Zhao Peng

Ben,

The content of /etc/redhat-release file shows:

Red Hat Enterprise Linux AS release 4 (Nahant Update 2)

Thank you.
Zhao

Ben Scott wrote:

[CC'ing the list with the OP's permission.  Please include the list in
any replies.]

On 1/2/06, Zhao Peng [EMAIL PROTECTED] wrote:
  

 Thank you for still paying attention to my partition problem.



  Sure thing.  Sorry for the delay in getting back to you.  :)

  

 1  What release of Red Hat Enterprise Linux are you running?
 It's Red Hat Enterprise Linux AS (2.6.9-22.EL)



  I'm most interested in the release of the whole distribution.  RHEL
2.1, 3, 4...?  If you're not sure, you should be able to find out by
taking a look at the /etc/redhat-release file.

  2.6.9-22.EL is the kernel version.  I suppose kernel 2.6 implies
RHEL 4, but I'd like to be sure.

  Once I know what distribution and release you have, I can look up
what tools it ships with, and what features it enables, that we might
have to worry about.

  

 2 What are your partitions used for?

 df output:

 Filesystem   1K-blocks  Used Available Use% Mounted on
 /dev/hda5  5036284   1130792   3649660  24% /
 /dev/hda1   101086  8508 87359   9% /boot
 none241772 0241772   0% /dev/shm
 /dev/hda7  6192896 42204   5961952   1% /home
 /dev/hda2  5036316   3299548   1480936  70% /usr
 /dev/hda3  5036316105340   4675144   3% /var



  Okay, it looks like you're in good shape.  Particular things I note
from the above:

- You're using plain partitions (not LVM or RAID or whatever)
- You have a separate boot partition (hda1)
- You have a big home partition (hda7), with plenty of space free, at
the end of the disk

  The easiest way to tackle a dual-boot would then be:

- Shrink your home partition down to make room
- Install the new system in an additional partition (hda8)
- Share the same swap partition (hda6) for both installs
- Share the same boot partition (hda1) for both installs
- Possibly share the home partition (but one thing at a time)

  First, before proceeding, the obligatory warning: *BACK UP
EVERYTHING*.  If you don't have proper backups, you're gonna loose
data.  Maybe not for this adventure, but eventually.   Even if you
decide not to try this, you should still back up everything.  It's the
one rule that applies regardless of hardware or OS.  You have been
warned.

  The kernel boot files (vmlinuz and initrd) have unique names across
Red Hat distributions, so you have use the same boot partition for
both distros.  This actually works out in your favor.  Each can
install it's own kernel files in the boot partition, update the grub
config file, and generally be happy.  GRUB will let you choose between
installs at boot.  I'm pretty sure the Red Hat installer, anaconda,
will handle it all for you.

  The swap partition isn't used between boots, so you can use the same
one for both installs.

  The exact commands you'll need to use to resize your home partition
will depend on the release of RHEL, as well as the file system type. 
I expect you have an EXT3 filesystem, but again, best to be sure.  Use

the mount command to see what is currently mounted.  You should see
a line that looks something like this:

/dev/hda7 on /home type ext3 (rw)

  Just report the type -- in the above, ext3.

  Once we've got the details established, we should be well on our way.

  

 swapon -s output:
 Nothing showed in terminal.



  Odd.  swapon -s should show you the status (currently active) swap
spaces.  From your df output, it's a pretty good bet that hda6 is
your swap partition, and you reported the same in a previous post.  I
would expect it to be there.  Well, it's probabbly not worth worrying
about.

  Cheers!

-- Ben

  


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: extract string

2006-01-10 Thread Zhao Peng

Hi All,

First I really cannot be more grateful for the answers to my question 
from all of you, I appreciate your help and time. I'm especially touched 
by the outpouring of response on this list., which I have never 
experienced  before anywhere else.


Secondly I'm sorry for the big stir-up as to homework problems which 
flooded the list, since I'm origin of it.


Kenny, your grep univ abc.txt | cut -f3 -d, | sed s/\//g  dev.txt 
works. I mis-read /\ as a simliar sign on the top of 6 key on the 
keyboard(so when I typed that sign, I felt strange that it is much 
smaller than /\, but didn't realize that they just are not the same 
thing), instead of forward slash and back slash. I felt really 
embarrassed with my stupid mistake. //blush


Kenny, regarding missing column issue, let me try to explain it again. 
Below is quoted from my original post:



Also, if one column is missing, and , is used to indicate that missing 
column, like the following (2nd column of 3rd line is missing):

name,age,school
jerry ,21,univ of Vermont
jesse,,,Dartmouth college
jack,18,univ of Penn
john,20,univ of south Florida
===

You said that there is an extra column in the 3rd line. I disagree 
with you from my perspective. As you can see, there are 3 commas in 
between jesse and Dartmouth college. For these 3 commas, again, if 
we think the 2nd one as an merely indication that the value for age 
column is missing, then the 3rd line will be be read as [jesse, 
MISSING, Dartmouth college], not [jesse,empty,empty, Dartmouth 
college] as you suggested.


Paul, as to your simplest by what measurement question. I was thinking 
of both easiest to remember and easiest to understand when I was 
posting my question. Now I desire for most efficient approach. I know 
that will be my homework.


BTW,
A bit about me: I'm a junior SAS programmer at Dartmouth Medical school. 
(FYI: core strength of SAS lies in statistical analysis, I think, so you 
could say it's a statistical software, check www.sas.com). We run SAS on 
a RedHat server, but I basically know nothing about linux before I 
started working on this position(July, 2005). Fortunately, SAS 
programming doesn't require much linux knowledge. However, as you can 
imagine, at least I need to know some basic linux commands since I work 
on linux platform.


Part of my primary job responsibilities is to convert raw data into SAS 
data sets. My extract string question comes from processing a raw data 
file in .txt format, which doesn't have any documentation, except the 
variable list. By looking at the raw data, I know that each variable is 
separated by a comma. For one particular variable(column) called 
school, the length of some of its value is quite long(like: Univ of 
Wisconsin at Madison, Health Sci Ctr), but I don't know the definite 
length. I need to know it, because if the length I specify it not 
enough, only partial values will be read. Many of its values contain 
univ, so I just thought if I could extract all strings containing 
univ from that variable(column), I will have a better chance to figure 
out the length of school. That's why I had this question.


Thank you all again!

Zhao
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: Follow-up: Red Hat / Fedora dual boot

2005-12-30 Thread Zhao Peng

Hi Jerry,

Thanks for your suggestions.

Below is what I did.

1 regular boot up from Knopixx
2 bring up konsole
3 su -
4 swapoff /dev/hda6
5 qtparted

For step 5, I got a line saying qtparted: cannot connect to X server

So I started qtparted via K menu - systems, and  tried to resize 
hda4 (which is extended partition, and still the only partition the 
resize is not gray-out). Hda4 has size of  46.04 gb, consisting of 
hda5 thru hda7, used space for these 3 partitions is less than 1 gb.


So I right-clicked on hda4, and selected resize, and set Free after 
space at 40 gb, and committed change from File menu. The pop-up 
windows says that the operation is successful. BUT, hda4 is still 46.04 
gb, and nothing changed! So I tried to commit changes from Device 
menu, the operation is also successful, but it didn't make any 
difference: hda4 was NOT resized.


Gee, I'm sooo frustrated. //crying..

z
___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


Re: Follow-up: Red Hat / Fedora dual boot

2005-12-30 Thread Zhao Peng
Thank you folks. Now I was able to start qtparted from shell as root.

But, I ran into the following error message:

Filesystem has incompatible feature enabled

Same error happened when I used parted. Not surprising, I believe qtparted is sort of GUI version of parted.
I googled and found no good solution to solve the problem above.

The whole dual-boot thing has been time-consuming, and I think it's time for me to forget it and get some real work done.

Thank you all again.

Zhao
On 12/30/05, Neil Schelly [EMAIL PROTECTED] wrote:
On Friday 30 December 2005 09:42 am, Zhao Peng wrote: 1 regular boot up from Knopixx 2 bring up konsole2a xhost + 3 su - 4 swapoff /dev/hda6 5 qtparted For step 5, I got a line saying qtparted: cannot connect to X server
That will be fixed by step 2a added above. So I started qtparted via K menu - systems, andtried to resizeThat means you didn't open QTParted as root.The step I added above will let
you do just that, by opening up permissions to your X session to other users(ie root).Normally, X sessions are only accessible to the user runningthem. Gee, I'm sooo frustrated. //crying..
No need for that now... ;-)-N


Follow-up: Red Hat / Fedora dual boot

2005-12-29 Thread Zhao Peng

Hi,

I'm back to bug you guys on this thread. (BTW, It's very likely that I 
may use some terms incorrectly, due to my unfamiliarity with linux. 
Sorry about that. :) )


In case you may forget, let me repeat my situation:

only 1 hard drive, and only RedHat Enterprise installed on it, and no 
unallocated free space.


In order to resize the hard drive to give some space to Fedora, I used 
Qtparted on Knoppix live DVD (I don't have Partition Magic). 
Unfortunately it didn't work.


My current RedHat partition is as follows:

hda1   ext3
hda2   ext3
hda3   ext3
hda4   extended
hda5   ext3
hda6   swap
hda7   ext3

Note: hda4 consists of hda5, hda6, and hda7.

When I right-click on the above partitions one by one, resize is 
gray-out for all partitions, except hda4. So I went ahead to resize 
hda4. I set Free space after to 30 gb. (hda4 has 42 gb, and no more 
than 3 gb is used). Then I got a small pop-up window w/o any information 
on it, except for a question mark.


I googled and found the table at this link: 
http://qtparted.sourceforge.net/features.en.html


From this table, I suspect that Qtparted can NOT resize ext3/ext2 type 
partition. Am I right?


If this is the case, what other EASY tools do you recommend me to try? 
(I also tried Gparted live CD at 
http://gparted.sourceforge.net/livecd.php, but had problems booting the 
machine from it)


Thank you for all input you have given. I really appreciate that.

Zhao


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss


any good light shareware/freeware to detect hardware configuration?

2005-12-16 Thread Zhao Peng
Hi,This morning around 11:00am I'm going to buy an used desktop.Before I make the purchase, I hope to know its hardware specifics.So could anyone please shed some light on what small shareware/freeware I can try to detect hardware configuration?
Thank you very much!ZhaoBTW,The seller asks for around $300 for this desktop (Shuttle XPC Mini Desktop Computer: 60 GB HD, DVD-RW Drive, 512 DDR Memory. Condition: like new). Does it sound a fair price given the information in his Ad above?



Re: any good light shareware/freeware to detect hardware configuration?

2005-12-16 Thread Zhao Peng
I don't know what operating system is on that desktop, but I suppose 
it's not Linux.


So my question might well be off-topic here, but I wanted to try my luck 
here, since this group looks very active and you guys are quite 
responsive to any question, including a recent thread about where to 
buy a new system :)


Thanks,
Zhao

Zhao Peng wrote:

Hi,

This morning around 11:00am I'm going to buy an used desktop.

Before I make the purchase, I hope to know its hardware specifics.

So could anyone please shed some light on what small 
shareware/freeware I can try to detect hardware configuration?


Thank you very much!

Zhao

BTW,
The seller asks for around $300 for this desktop (Shuttle XPC Mini 
Desktop Computer: 60 GB HD, DVD-RW Drive, 512 DDR Memory. Condition: 
like new). Does it sound a fair price given the information in his Ad 
above?
  


___
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss