comp.unix.shell
  Home FAQ Contact Sign in
comp.unix.shell only
 
Advanced search
July 2008
motuwethfrsasuw
 123456 27
78910111213 28
14151617181920 29
21222324252627 30
28293031    31
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.unix.shell Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  tricks? to minimize forking (for cygwin bash scripts)         


Author: Name withheld by request
Date: Jul 17, 2008 17:58

in Ex 1 was a fork saved w/r to Ex 2?:

Ex 1
log=$(< /tmp/mylogfile)
echo "$log"
Ex 2
cat /tmp/mylogfile

what about?:

Ex 1
myfilterxx <<<"one line of info here"

Ex 2
echo "one line of info here"|myfilterxx

--
thanks much
7 Comments
  Re: grep exact         


Author: onlineviewer
Date: Jul 17, 2008 10:58

On Jul 17, 1:51 pm, Bill Marcum bellsouth.net> wrote:
> On 2008-07-17, onlineviewer gmail.com> wrote:
>
>
>
>
>
>> On Jul 17, 12:08 pm, mop2 wrote:
>>> On Thu, 17 Jul 2008 12:44:49 -0300, onlineviewer gmail.com> wrote:
>>>> hello All,
>
>>>> I am trying to grep exactly 2 digits at the end of a line.
>
>>>> ls -l | grep file.'[2-8][2-8]$'
>
>>>> iI thought that would work, but no luck
>>>> Thanks,
>
>>> ls -l file.[2-8][2-8]
> ...
Show full article (0.86Kb)
7 Comments
  How to disable cp error message in bash?         


Author: PengYu.UT
Date: Jul 17, 2008 10:50

Hi,

I tried the following command. I don't what bash to report the error
message when there is no *.sh files. Is there a way to do it?

~$ cp /bin/*.sh ./
cp: cannot stat `/bin/*.sh': No such file or directory

Thanks,
Peng
5 Comments
  grep exact         


Author: onlineviewer
Date: Jul 17, 2008 08:44

hello All,

I am trying to grep exactly 2 digits at the end of a line.

ls -l | grep file.'[2-8][2-8]$'

iI thought that would work, but no luck
Thanks,
6 Comments
  Use awk to get the last field of a record         


Author: nickli2000
Date: Jul 17, 2008 08:01

Hi,

I have the following records in a file:

CD NYC Car|0|20|07/10/2008| |6555.25|885|6347|
AB LA Home|0|20|07/15/2008| |885.25|665|4567|
AB BS Finance|0|20|06/22/2008| |675.25|65|877|
....

I need to get the last field of the first field separated by "|",
so the output will be:
Car
Home
Finance

I need to use AWK to do this since I also parse other records in
this file and output them. Here is parts of the code:

awk '/START-OF-DATA/,/END-OF-DATA/ { FS="|"; sp=index($1," "); if
(($0~/\|/) && ($2="0") && sp>4 )\ {print substr($1,sp-4,4),"|",$4,"|",
$5,"|",substr($1,1,sp-5),"|",substr($1,10),"|" } else \
{print substr($1,sp-1,4),"|",$4,"|",$5,"|",substr($1,1,sp-2),"|"}}'
$SOURCEFILE > $DATAFILE
Show full article (0.88Kb)
2 Comments
  select a few columns from file where field seperator is the same as character in field text         


Author: m.desai18
Date: Jul 17, 2008 07:02

I want to extract fields 3,4 and 8 from a file which looks like below:

AAA ,01,001,"XX,YY ",5,10, "AAAA ", 10.25
BBB ,01,002,"XXX,YY ",15,16, "AAAA ", 10.25
CCC ,00,003,"XXYY ",63,156, "AA'BB ", 11
DDD ,00,004,"XXYY.ZZ ",5,10, "AA'CC ", 09.99

Cut command does not work as the field seperator (comma) is part of
field text for field 4 in a few lines.

The table in which I am inserting the fields should look like below:

Table
Field1 Field2 Field3
001 XX,YY 10.25
002 XXX,YY 10.25
003 XXYY 11
004 XXYY.ZZ 9.99

Please let me know how to deal with this.
5 Comments
  parse file name         


Author: rogv
Date: Jul 17, 2008 05:39

How can I parse file names that looks like this:

20080701-051214.filename1.txt
20080803-013412.filename2.txt

so that the files will look like this:

filename1.txt
filename2.txt
3 Comments
  optional exit statement         


Author: rudra
Date: Jul 17, 2008 00:20

here is an easier version of what i want to do

Code:

#!/bin/bash
echo "Enter file name"
echo "You can enter maximum 3 file"

for (( i=1; i<=3;i++))
until [ "$*" = "" ]
do
echo "Enter file ${i}"
read fil_$i
done
//do the rest of the code

the probleam is, my input needs three input. but what i want to do is
to put an optin of optional break, say instead of three, i have only
one input ...so, if i put "0", the code should ixit for loop and do
the rest of the things.
how can i do that?
3 Comments