[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 110: Undefined array key "cached"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 111: Undefined array key "normal"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 112: Undefined array key "total"
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3391: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3393: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3394: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3395: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
Cabrillo College Linux Classes • View topic - oops!

oops!

Introduction to UNIX/Linux

oops!

Postby Diane Dymesich on Wed Nov 05, 2008 12:18 pm

Rich,
I tried out the sample test question sort shows > shows on the file dogsinorder,
and I can't remember how to fix it! I know we did an exercise in the last class on that very thing, right?
Thanks,
Diane
Diane Dymesich
 
Posts: 31
Joined: Wed Sep 03, 2008 7:27 pm

Re: oops!

Postby Rich Simms on Wed Nov 05, 2008 2:53 pm

Go ahead and create a [i]shows[/i] file with redirection:

[code]
[rsimms@opus ~]$ echo House > shows
[rsimms@opus ~]$ echo ER >> shows
[rsimms@opus ~]$ echo BBC >> shows
[rsimms@opus ~]$ echo 440 >> shows
[rsimms@opus ~]$ cat shows
House
ER
BBC
440
[/code]

Now try sort shows > shows

Can you explain what is happening? Use this forum topic to work out what is going on here. It is NOT doing what you might think it is doing. You have to think about the order bash is doing things.

Let the posts begin!

- Rich
User avatar
Rich Simms
Site Admin
 
Posts: 640
Joined: Thu May 15, 2008 2:44 pm

Re: oops!

Postby Michael Wicherski on Wed Nov 05, 2008 3:36 pm

Well it overwrites the shows file with nothing when you do that; not exactly sure why. I would say it is because you are hooking up stdin to stdout by doing that and sort isn't getting anything from stdin but that seems wrong.

You get the same result if you try piping it into tee as well as redirecting stdin to shows.
It seems sort doesn't like to share what it prints out, even though it is definitely printing to stdout .


In any case you could fix this by using the sort option which saves to an output file, which here is the same file as input so i color coded it to make it more readable

[color=#FF0000]sort [/color][color=#00FF00]-o[/color] [color=#FF8000]shows [/color]shows

[color=#FF0000]command[/color]
[color=#00FF00]option [/color]
[color=#FF8000]output file[/color]
input file


P.S. the order bash is doing things

command sort
pass it the file shows
idle

show opens and reads shows
then prints output to stdout (which for some reason you can't redirect! :? )
Michael Wicherski
 
Posts: 140
Joined: Mon Sep 01, 2008 5:23 am


Return to CIS 90 - Fall 2008

Who is online

Users browsing this forum: No registered users and 0 guests

cron