Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have this homework question. I looked at the man page for sort and I believe the answer is -o, --output=FILE Is that correct?

It is a Fedora server.

We're supposed to look on man pages, if there is no man page related to the subject than use an info page. If no info page exists either than use the internet.

share|improve this question

marked as duplicate by Michael Mrozek Sep 19 '13 at 6:31

This question was marked as an exact duplicate of an existing question.

I've edited out your additional questions. It's bad practice on Stack Exchange to combine questions like this. – strugee Sep 19 '13 at 6:19
Sorry. Is there any way to delete the question? So that I can redo it. – user2227702 Sep 19 '13 at 6:21
No, you don't have to delete it. I edited it for you (it'll be approved by the community soon) but in the future you can edit your question right under the tags. And welcome to Stack Exchange! – strugee Sep 19 '13 at 6:24

Sorting a file named foo in place - sort of:

set TMP=$(mktemp)
sort foo > $TMP
mv $TMP foo

This redirects the output of sort into a temporary file, which then replaces foo.

share|improve this answer
This will result in an empty foo. The shell will open foo for writing and truncate it before sort even starts – Michael Mrozek Sep 19 '13 at 6:28
This works, but I wouldn't exactly call writing the whole thing out to a new file "in-place" :). On the other hand, it's the same thing -o does, and that's clearly what the teacher expected – Michael Mrozek Sep 19 '13 at 6:43
Thanks everyone – user2227702 Sep 19 '13 at 6:47
@user2227702 you don't have to thank people - instead, upvote! (You can't do this yet but it's only 5 rep) – strugee Sep 19 '13 at 6:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.