Sort Command - Writing Output to File

I'm attempting to use the sort command to sort a postfix transport.map file into alphabetical order. when I am logged into the box, and su'd I can go to the directory, and type "sort transport.map" and it correctly displays what I want to stdout. However when I try to write the output to a file it generates a blank file.

I've tried:

sort -o transport2.map transport.map
sort transport.map -o transport2.map
sort transport.map > transport2.map

 I've also tried all the previous using full path names. Any ideas what I am doing wrong?

Thanks in advance.
kishvetAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mr_egyptianConnect With a Mentor Commented:
try:

sort --output=transport.sorted transport.map
0
 
kishvetAuthor Commented:
Tried the above, still a blank text file is created named transport.sorted, im not quite sure why the output to file doesnt work when the outputt o stdout works just fine.
0
 
mr_egyptianConnect With a Mentor Commented:
Sorry fot the late reply, but the above works fine for me on a simple file of unsorted chars. What happens if you try a file such as:

-------cut-----------
g
a
d
c
b
f
e
-------cut-----------
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
sda100Connect With a Mentor Commented:
Hi kishvet,

Following on from mr_egyptian's suggestion, are you sure it is a 0-byte file that is created, or is it just lots of leading blanks?

It may seem dumb, but are you logged on as root or running under sudo?

Steve :)
0
 
gheistCommented:
Your disk is almost full. It has hit 10% of disk accesible only by root. If not in that directory then in users home, /var or /tmp.
0
 
kishvetAuthor Commented:
Sorry For Late Response Myself, I was away for a week.

The Short file with letters works, generates the output file correctly.

It was exaclty the same size as the initial file.
0
 
kishvetAuthor Commented:
I feel dumb now :/

I found out what the problem was, i had blank lines throughout the file, due to its length, to break it up for readability. What i didnt think of was that sort was putting all these blank lines on top, pushing the text off the standard screen. I viewed this as a blank file and deleted it every time.

Going to Split Points Since I wasted Your Time.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.