Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Greeny boy needs your help. script "sort" Post 303028403 by fohatadri on Monday 7th of January 2019 09:08:55 AM
Old 01-07-2019
Greeny boy needs your help. script "sort"

Hello!

I have an issue with sorting or pasting. Do not know what the problem is, been trying to fix it for days. I think I'm stupid.
My home task sounds like this: create 100 files with 1 random number ranging from 1 to 1000.
Then paste all numbers from those 100 files to 1 complete file and sort it from smallest to highest.
This is my script:
Code:
#!/bin/bash
rm -rf DATA
mkdir DATA
for x in {1..100}
do
touch DATA/$x.txt
shuf -i 1-1000 -n 1 > DATA/$x.txt
done
paste DATA/*.txt > DATA/ALL.txt
sort -g DATA/ALL.txt > DATA/ALL_sorted.txt

Problem is that all the data in ALL.txt is not in one column but in many and file ALL_sorted.txt is the same. Nothing sorts nothing.
HELP! I think the issue is in pasting but dunno.

Last edited by Neo; 01-07-2019 at 10:10 AM.. Reason: Added Code Tags. Please read the rules. They are important.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

Meaning of "b" modifier in "sort" command

I need to sort the following file by the rhdiskpower devices in the last column: Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 1024 851 1024 OCRVOT1_0000 OCRVOT1_0000 System UNKNOWN ... (3 Replies)
Discussion started by: wjssj
3 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Shell Programming and Scripting

Is it Possible to sort a list of hexadecimal numbers using "sort" command?

Hello Everybody :) !!!. i have question in mind, is it possible to sort a list of hexadecimal numbers using "sort" command? (9 Replies)
Discussion started by: Kesavan
9 Replies

5. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

6. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

7. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
Mojo::Command(3pm)					User Contributed Perl Documentation					Mojo::Command(3pm)

NAME
Mojo::Command - Command base class SYNOPSIS
# Lower case command name package Mojolicious::Command::mycommand; # Subclass use Mojo::Base 'Mojo::Command'; # Take care of command line options use Getopt::Long 'GetOptions'; # Short description has description => "My first Mojo command. "; # Short usage message has usage => <<"EOF"; usage: $0 mycommand [OPTIONS] These options are available: -s, --something Does something. EOF # <suitable Futurama quote here> sub run { my $self = shift; # Handle options local @ARGV = @_; GetOptions('s|something' => sub { $something = 1 }); # Magic here! :) } DESCRIPTION
Mojo::Command is an abstract base class for Mojo commands. See Mojolicious::Commands for a list of commands that are available by default. ATTRIBUTES
Mojo::Command implements the following attributes. "description" my $description = $command->description; $command = $command->description('Foo!'); Short description of command, used for the command list. "quiet" my $quiet = $command->quiet; $command = $command->quiet(1); Limited command output. "usage" my $usage = $command->usage; $command = $command->usage('Foo!'); Usage information for command, used for the help screen. METHODS
Mojo::Command inherits all methods from Mojo::Base and implements the following new ones. "app" my $app = $command->app; Currently active application. # Introspect say "Template path: $_" for @{$command->app->renderer->paths}; "chmod_file" $command = $command->chmod_file('/home/sri/foo.txt', 0644); Portably change mode of a file. "chmod_rel_file" $command = $command->chmod_rel_file('foo/foo.txt', 0644); Portably change mode of a file relative to the current working directory. "class_to_file" my $file = $command->class_to_file('Foo::Bar'); Convert a class name to a file. Foo::Bar -> foo_bar FOO::Bar -> foobar FooBar -> foo_bar FOOBar -> foobar "class_to_path" my $path = $command->class_to_path('Foo::Bar'); Convert class name to path. Foo::Bar -> Foo/Bar.pm "create_dir" $command = $command->create_dir('/home/sri/foo/bar'); Portably create a directory. "create_rel_dir" $command = $command->create_rel_dir('foo/bar/baz'); Portably create a directory relative to the current working directory. "get_all_data" my $all = $command->get_all_data; my $all = $command->get_all_data('Some::Class'); Extract all embedded files from the "DATA" section of a class. "get_data" my $data = $command->get_data('foo_bar'); my $data = $command->get_data('foo_bar', 'Some::Class'); Extract embedded file from the "DATA" section of a class. "help" $command->help; Print usage information for command. "rel_dir" my $path = $command->rel_dir('foo/bar'); Portably generate an absolute path for a directory relative to the current working directory. "rel_file" my $path = $command->rel_file('foo/bar.txt'); Portably generate an absolute path for a file relative to the current working directory. "render_data" my $data = $command->render_data('foo_bar', @args); Render a template from the "DATA" section of the command class. "render_to_file" $command = $command->render_to_file('foo_bar', '/home/sri/foo.txt'); Render a template from the "DATA" section of the command class to a file. "render_to_rel_file" $command = $command->render_to_rel_file('foo_bar', 'foo/bar.txt'); Portably render a template from the "DATA" section of the command class to a file relative to the current working directory. "run" $command->run; $command->run(@ARGV); Run command. Meant to be overloaded in a subclass. "write_file" $command = $command->write_file('/home/sri/foo.txt', 'Hello World!'); Portably write text to a file. "write_rel_file" $command = $command->write_rel_file('foo/bar.txt', 'Hello World!'); Portably write text to a file relative to the current working directory. SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>. perl v5.14.2 2012-09-05 Mojo::Command(3pm)
All times are GMT -4. The time now is 07:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy