Cron is sorting with ls differently

I am running a script in cron and it is does an 'ls' differently than
when I run the script in my shell at the command line. I ran a quick
experimen to see how cron sorts file with ls ( I also tried ls -x).

I made a folder with these files

afile Afile bfile Bfile cfile Cfile

When I run my script at the command line, they get sorted
alphabetically, the way I want it, as follows

afile Afile bfile Bfile cfile Cfile

When the script runs in cron the files are sorted as follows

Afile Bfile Cfile afile bfile cfile


I tried add /home/myuser/.cshrc to the first line of my shell but no
luck

Any ideas
spacemancw [ Mo, 31 März 2008 03:18 ] [ ID #1932368 ]

Re: Cron is sorting with ls differently

On 2008-03-31, spacemancw <spacemancw [at] yahoo.com> wrote:
>
>
> I am running a script in cron and it is does an 'ls' differently than
> when I run the script in my shell at the command line. I ran a quick
> experimen to see how cron sorts file with ls ( I also tried ls -x).
>
> I made a folder with these files
>
> afile Afile bfile Bfile cfile Cfile
>
> When I run my script at the command line, they get sorted
> alphabetically, the way I want it, as follows
>
> afile Afile bfile Bfile cfile Cfile
>
> When the script runs in cron the files are sorted as follows
>
> Afile Bfile Cfile afile bfile cfile
>
>
> I tried add /home/myuser/.cshrc to the first line of my shell but no
> luck
>
Did you source .cshrc? Otherwise, any variables set in there would be
lost. The variable you need to set is LANG or LC_COLLATE.
Bill Marcum [ Mo, 31 März 2008 03:51 ] [ ID #1932369 ]

Re: Cron is sorting with ls differently

sort -f will probably help..



On 30 Mart, 21:18, spacemancw <spacema... [at] yahoo.com> wrote:
> I am running a script in cron and it is does an 'ls' differently than
> when I run the script in my shell at the command line. I ran a quick
> experimen to see how cron sorts file with ls ( I also tried ls -x).
>
> I made a folder with these files
>
> afile =A0Afile =A0bfile =A0Bfile =A0cfile =A0Cfile
>
> When I run my script at the command line, they get sorted
> alphabetically, the way I want it, as follows
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 afile =A0Afile =A0bfile =A0Bfile =
=A0cfile =A0Cfile
>
> When the script runs in cron the files are sorted as follows
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Afile =A0Bfile =A0Cfile =A0afile =
=A0bfile =A0cfile
>
> I tried add /home/myuser/.cshrc to the first line of my shell but no
> luck
>
> Any ideas
Karabasan [ Mo, 31 März 2008 04:13 ] [ ID #1932370 ]

Re: Cron is sorting with ls differently

On Mar 30, 9:51=A0pm, Bill Marcum <marcumb... [at] bellsouth.net> wrote:
> On 2008-03-31, spacemancw <spacema... [at] yahoo.com> wrote:
>
>
>
>
>
> > I am running a script in cron and it is does an 'ls' differently than
> > when I run the script in my shell at the command line. I ran a quick
> > experimen to see how cron sorts file with ls ( I also tried ls -x).
>
> > I made a folder with these files
>
> > afile =A0Afile =A0bfile =A0Bfile =A0cfile =A0Cfile
>
> > When I run my script at the command line, they get sorted
> > alphabetically, the way I want it, as follows
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 afile =A0Afile =A0bfile =A0Bfile=
=A0cfile =A0Cfile
>
> > When the script runs in cron the files are sorted as follows
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Afile =A0Bfile =A0Cfile =A0afile =
=A0bfile =A0cfile
>
> > I tried add /home/myuser/.cshrc to the first line of my shell but no
> > luck
>
> Did you source .cshrc? Otherwise, any variables set in there would be
> lost. =A0The variable you need to set is LANG or LC_COLLATE.- Hide quoted =
text -
>
> - Show quoted text -


Thanx

wheb I type locale at my comman line I get

LANG=3Den_US.UTF-8
LC_CTYPE=3D"en_US.UTF-8"
LC_NUMERIC=3D"en_US.UTF-8"
LC_TIME=3D"en_US.UTF-8"
LC_COLLATE=3D"en_US.UTF-8"
LC_MONETARY=3D"en_US.UTF-8"
LC_MESSAGES=3D"en_US.UTF-8"
LC_PAPER=3D"en_US.UTF-8"
LC_NAME=3D"en_US.UTF-8"
LC_ADDRESS=3D"en_US.UTF-8"
LC_TELEPHONE=3D"en_US.UTF-8"
LC_MEASUREMENT=3D"en_US.UTF-8"
LC_IDENTIFICATION=3D"en_US.UTF-8"
LC_ALL=3D

so am I supposed to load this under cron?
I added all these lines to the top of my script but it didn't make a
difference

thanx
spacemancw [ Mo, 31 März 2008 04:36 ] [ ID #1932372 ]

Re: Cron is sorting with ls differently

On Mar 30, 10:13=A0pm, Karabasan <dogan... [at] gmail.com> wrote:
> sort -f =A0 will probably help..
>
> On 30 Mart, 21:18, spacemancw <spacema... [at] yahoo.com> wrote:
>
> > I am running a script in cron and it is does an 'ls' differently than
> > when I run the script in my shell at the command line. I ran a quick
> > experimen to see how cron sorts file with ls ( I also tried ls -x).
>
> > I made a folder with these files
>
> > afile =A0Afile =A0bfile =A0Bfile =A0cfile =A0Cfile
>
> > When I run my script at the command line, they get sorted
> > alphabetically, the way I want it, as follows
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 afile =A0Afile =A0bfile =A0Bfile=
=A0cfile =A0Cfile
>
> > When the script runs in cron the files are sorted as follows
>
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Afile =A0Bfile =A0Cfile =A0afile =
=A0bfile =A0cfile
>
> > I tried add /home/myuser/.cshrc to the first line of my shell but no
> > luck
>
> > Any ideas

Thanx
sort -f did it
spacemancw [ Mo, 31 März 2008 05:36 ] [ ID #1932374 ]
Linux » comp.unix.shell » Cron is sorting with ls differently

Vorheriges Thema: echo "\000root\@test.com\000root" | base64
Nächstes Thema: Re: while /usr/bin/read