Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
coreutils seq not as advertised? [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
shabbychef
n00b
n00b


Joined: 08 Jun 2005
Posts: 43

PostPosted: Wed Apr 23, 2008 8:52 pm    Post subject: coreutils seq not as advertised? [SOLVED] Reply with quote

I have sys-apps/coreutils-6.9-r1 installed (and sys-apps/man-pages-2.78, app-shells/bash-3.2_p17-r1). my seq (in coreutils) seems borked. For example, the info page for seq says:
Quote:

...snip...
You can get finer-grained control over output with `-f':

$ seq -f '(%9.2E)' -9e5 1.1e6 1.3e6
(-9.00E+05)
( 2.00E+05)
( 1.30E+06)

If you want hexadecimal integer output, you can use `printf' to
perform the conversion:

$ printf '%x\n' `seq 1048575 1024 1050623`
fffff
1003ff
1007ff
...snip..

But when I try these in my shell, I get:
Quote:

$ seq -f '(%9.2E)' -9e5 1.1e6 1.3e6
bash: [: -f: integer expression expected
bash: [: -f: integer expression expected
-f
$ printf '%x\n' `seq 1048575 1024 1050623`
0

In fact, my seq does not seem to do anything useful, and is rather bizarre:
Quote:

$ seq 3
bash: [: 3: unary operator expected
bash: [: 3: unary operator expected
3
$ seq 1 3
1 2 3 4
$ seq 1 3 999999
1 2 3 4

for what its worth, I looked at some things:
Quote:

$ file `which seq`
/usr/bin/seq: symbolic link to `/bin/seq'
$ file /bin/seq
bin/seq: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), stripped
$ equery b /bin/seq
[ Searching for file(s) /bin/seq in *... ]
sys-apps/coreutils-6.9-r1 (/bin/seq)

I am going to try to re-emerge coreutils, but am not sure what's going on here. the seq I have does nothing like what I would expect, or is the info page stale? It seems like bash is interpreting 'seq' to mean something other than /usr/bin/seq?
_________________
shabby


Last edited by shabbychef on Wed Apr 23, 2008 9:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
yabbadabbadont
Advocate
Advocate


Joined: 14 Mar 2003
Posts: 4791
Location: 2 exits past crazy

PostPosted: Wed Apr 23, 2008 8:59 pm    Post subject: Reply with quote

I think that bash has a built-in "seq" command. You need to either use the full path to the one from coreutils, or preface your command with '\'.

Try these and see if they work:
Code:
\seq -f '(%9.2E)' -9e5 1.1e6 1.3e6

and
Code:
/bin/seq -f '(%9.2E)' -9e5 1.1e6 1.3e6
Back to top
View user's profile Send private message
shabbychef
n00b
n00b


Joined: 08 Jun 2005
Posts: 43

PostPosted: Wed Apr 23, 2008 9:10 pm    Post subject: [solved] Reply with quote

yabbadabbadont wrote:
I think that bash has a built-in "seq" command. You need to either use the full path to the one from coreutils, or preface your command with '\'.

Try these and see if they work:
Code:
\seq -f '(%9.2E)' -9e5 1.1e6 1.3e6

and
Code:
/bin/seq -f '(%9.2E)' -9e5 1.1e6 1.3e6


yay. that worked! Nowhere, however, can I figure out what bash's builtin seq does, though...
_________________
shabby
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9932
Location: almost Mile High in the USA

PostPosted: Fri Apr 25, 2008 12:27 am    Post subject: Reply with quote

Might want to try

Code:
type -path seq


to see what default seq you're running...

Maybe you have some script 'seq' somewhere? or an alias/function? Not sure if bash is supposed to have a 'seq' ...

[ This thread should be in 'other,' not 'kernel&hardware'? ]
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
shabbychef
n00b
n00b


Joined: 08 Jun 2005
Posts: 43

PostPosted: Fri Apr 25, 2008 6:38 pm    Post subject: Reply with quote

eccerr0r wrote:
Might want to try

Code:
type -path seq


to see what default seq you're running...

Maybe you have some script 'seq' somewhere? or an alias/function? Not sure if bash is supposed to have a 'seq' ...


did the following:
Code:

$ type -a seq
seq is a function
seq ()
{
    local lower upper output;
    lower=$1 upper=$2;
    if [ $lower -ge $upper ]; then
        return;
    fi;
    while [ $lower -le $upper ]; do
        echo -n "$lower ";
        lower=$(($lower + 1));
    done;
    echo "$lower"
}
seq is /usr/bin/seq
seq is /bin/seq

not sure where that function is defined, though. the info for type does not help me figure out how to find the seq function. I am assuming it is 'builtin'.


Quote:

[ This thread should be in 'other,' not 'kernel&hardware'? ]

yah, sorry. wasn't sure where to put it.
_________________
shabby
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9932
Location: almost Mile High in the USA

PostPosted: Fri Apr 25, 2008 8:49 pm    Post subject: Reply with quote

Looks like one of your login scripts is setting up a function that does something similar to coreutils seq, totally written as a script. Unfortunately bash doesn't support floats...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum