Sponsored Content
Top Forums Shell Programming and Scripting How to save sorted content of a inside the same file? Post 302918408 by rbatte1 on Tuesday 23rd of September 2014 06:34:01 AM
Old 09-23-2014
This is a common problem. When you run the command, the output file is opened (and overwritten) before you start to read the input, which by now is null. You command then exists as it finishes reading no input.

You will need to read the input and write to a separate output file. If need be, then rename (and overwrite) the input file thus:-
Code:
sort -o output input
mv output input

It does mean that you have to consider space for having the two files at the same time, even if just for a moment.



Robin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep content of files sorted by time stamp

egrep Date: *.html > out.htm I would like to grep the match as sorted by time stamp of the html files. how do I do that? (1 Reply)
Discussion started by: zer0
1 Replies

2. Solaris

Content of /var/sadm/pkc/<pkg>/save directory

Hi, What are the contents of /var/sadm/pkg/<pkg>/save directory. - It contains various patches with their id's. What does the "pspool" directory inside it contain? (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

3. Shell Programming and Scripting

how to add string inside the file's content

Hi, How to add string inside the file. In this case adding 63 in the beginning of each line. Thnks. e.g. what is inside the file Mobile Number Portability 9051151234 9051261345 9051393245 9051412345 9051507654 should like this as output: Mobile Number Portability (7 Replies)
Discussion started by: shtobias
7 Replies

4. Shell Programming and Scripting

Save output to file - inside a script ?

I'm using the following script to check cisco router health and I'd like to save output to a file, vty_runcmd.sh > /check/check-cisco-health script works and output is saved to a file. However using it in crontab file is created but output is not printed inside it. In crontab, */5 * * * *... (4 Replies)
Discussion started by: marmellata
4 Replies

5. Shell Programming and Scripting

Help - delete content inside square brackets under conditions

I have the file sed1.txt and I need to strip the brackets (]) and content inside them only when I have two or three letters followed by a colon. for example,it may be any letter, not just abc ] ] #-- cat sed1.txt 1 ] FISICA 2 ]PORTUGUES 3 ] ]MATEMATICA 4 ]]INGLES ] 5 ]QUIMICA 6... (2 Replies)
Discussion started by: dperboni
2 Replies

6. Shell Programming and Scripting

sed - delete content inside tags multiline

I need that a certain part of the content below excluded ==Image Gallery== followed by <gallery> and the content until </gallery> test SED1 ==Image Gallery== <gallery> Image:car1.jpg| Car 1<sup>1</sup> Imagem: car2.jpg| Car2<sup>2</sup> </gallery> test SED2 ==Image... (5 Replies)
Discussion started by: dperboni
5 Replies

7. Shell Programming and Scripting

awk : split file and rename and save in path according to content

Hello, I'm using Windows 7 ; sed, awk and gnuwin32 are installed. I have a big text file I need to manipulate. In short, I will have to split it in thousands of short files, then rename and save in a folder which name is based upon filename. Here is a snippet of my big input.txt file (this... (4 Replies)
Discussion started by: sellig
4 Replies

8. Shell Programming and Scripting

Problem while displaying(cat) file content inside telnet loop .

Hi Team, Not getting the file output inside my email which i am sending from unix box. . Please refer the below code : #!/bin/sh { sleep 5 echo ehlo 10.56.185.13 sleep 3 echo mail from: oraairtel@CNDBMUREAPZP02.localdomain sleep 3 echo rcpt to: saurabhtripathi@anniksystems.com... (1 Reply)
Discussion started by: tripathi1990
1 Replies

9. Shell Programming and Scripting

Replace content from a file and save

Hi, Right now there is a file called 'qm.ini' which is owned by mqm:mqm and I am trying to replace a line from this file with something else and save. I am using the below perl command to replace and save within a shell script with a different user called 'mqadm' which is also part of mqm... (1 Reply)
Discussion started by: bdpl
1 Replies

10. UNIX for Beginners Questions & Answers

How to get script to create a new file that lists folder content sorted by size?

I have a script that sorts and processes unsorted files to newly created directories. Its working great, but I am trying to understand the leanest method to get the script to create an additional file within each newly created directory that: Contains a list of all files in the directory... (4 Replies)
Discussion started by: Braveheart
4 Replies
vcatobj(1Vi)															      vcatobj(1Vi)

NAME
vcatobj - concatenate Vista data files SYNOPSIS
vcatobj [-option ...] [infile ...] [> outfile] DESCRIPTION
vcatobj copies the contents of one or more input files to an output file. All objects found in all input files (such as images, edge lists, and comments) are copied, in order, to the single output file. COMMAND LINE OPTIONS
vcatobj accepts the following options: -help Prints a message describing options. -in infile ... Specifies one or Vista data files to be input. -out outfile Specifies where to write the output as a Vista data file. Input files can be specified on the command line or allowed to default to the standard input stream. The output file can be specified by the -out option or allowed to default to the standard output stream. SEE ALSO
vcatbands(1Vi), Vista(7Vi) NOTES
All input files are read before the output file is written. The program vcatobj was originally be known as vcat, created by Art Pope. AUTHOR
Art Pope <pope@cs.ubc.ca> Vista Version 1.12 24 April 1993 vcatobj(1Vi)
All times are GMT -4. The time now is 03:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy