Solved

Sort Command - Writing Output to File

Posted on 2006-07-07
7
1,512 Views
Last Modified: 2013-11-22
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.
0
Comment
Question by:kishvet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 15

Accepted Solution

by:
mr_egyptian earned 375 total points
ID: 17088021
try:

sort --output=transport.sorted transport.map
0
 

Author Comment

by:kishvet
ID: 17091714
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
 
LVL 15

Assisted Solution

by:mr_egyptian
mr_egyptian earned 375 total points
ID: 17117667
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Assisted Solution

by:sda100
sda100 earned 125 total points
ID: 17128224
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
 
LVL 62

Expert Comment

by:gheist
ID: 17151971
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
 

Author Comment

by:kishvet
ID: 17154390
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
 

Author Comment

by:kishvet
ID: 17154428
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

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pauing printer deamon in AIX 10 66
OpenLDAP Proxy to Active Directy 6 576
How do disable only TLSv1.0 in Oracle Sun One 7.1 Server 9 149
awk sed 8 135
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question