Sponsored Content
Full Discussion: Looping through input/output
Top Forums UNIX for Beginners Questions & Answers Looping through input/output Post 302979914 by zajtat on Sunday 21st of August 2016 11:30:41 AM
Old 08-21-2016
Thank you all for your suggestions and explanations!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using Output from one command as input to another

This site has been very helpful thus far.. I thank you all in advance for sharing the knowledge. Let me get to it. I am trying to write a very small script to take away from the boredom of doing the same thing over and over. Everynow and again I have to get the hex value of a file using a... (2 Replies)
Discussion started by: BkontheShell718
2 Replies

2. UNIX for Advanced & Expert Users

input/Output settings

How can we view all the input/output settings of unix environment for a session (6 Replies)
Discussion started by: paritoshc
6 Replies

3. Shell Programming and Scripting

input -output file

Hi, I am having an Input file .which is having a list of names. comapring with our database , needs to write the out put in file called output.txt , format should be name--> country--->phone number could you please help me.. thanks in advance (7 Replies)
Discussion started by: hegdeshashi
7 Replies

4. Shell Programming and Scripting

perl: looping through the output of a 'system' command

Hi there could anybody point me in the right direction when it comes to looping through the output of a system command in perl (i.e. df -k) doing a test against each line to see if it matches? for example if i have a df -k output like this and I wanted to grab the lines that matched "sda" or... (3 Replies)
Discussion started by: rethink
3 Replies

5. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

6. Solaris

SVM Solaris 8 Problem. Metastat output looping

Hi friends, I'm newbie to SVM. Just wanna try installed it on one of our server (to do mirroring for disk0 and disk1) but i think im lost until now. :( the steps i've taken is as below:- 1.prtvtoc /dev/rdsk/c1t0d0s2 | fmthard -s - /dev/rdsk/c1t1d0s2 2.metadb -a -c 3 -f c1t0d0s7... (3 Replies)
Discussion started by: kronenose
3 Replies

7. Shell Programming and Scripting

Looping through for user input

Legends, I want to remain in the script until user passes the correct name. I had tried the below code; but it didn't work out. Please help echo "\nPlease enter the source system: \c" while read SYSTEM_NAME do if ]; then echo "\nMaking $SYSTEM_NAME as source system for particular... (5 Replies)
Discussion started by: sdosanjh
5 Replies

8. Shell Programming and Scripting

looping and saving output of each line separately

I have been trying this program for a long time. I am trying to read a file named "odon" line by line; read the first line, send it to do a command saved in a file "perm", once the first line has finished going through the content of the file perm, the result is saved with the number of the line.... (17 Replies)
Discussion started by: iconig
17 Replies

9. UNIX for Dummies Questions & Answers

Looping through the contents of array for output name

Hi all, I am trying to loop through the string contents of an array, to add it during the saving of the output files. I am trying this code to print each column and save it to unique file name, but it doesn't work. Thanks for any help. fnam=(japan usa uk) alldata.dat contained sample data... (1 Reply)
Discussion started by: ida1215
1 Replies

10. Shell Programming and Scripting

Looping over output of 'ls'

Hi, I have some output from 'ls' command and I want to loop over the output in a bash script. What would be a good way to go about it? For example, if the output of the ls command gives me 'prefix1 prefix2 prefix3', how can I set a loop that will iterate over these? many thanks! (5 Replies)
Discussion started by: pc2001
5 Replies
sort5(1)						      General Commands Manual							  sort5(1)

Name
       sort5 - internationalized System 5 sort and/or merge files

Syntax
       sort5 [-cmu] [-ooutput] [-ykmem] [-zrecsz] [-X] [-dfiMnr] [-btx] [+pos1 [-pos2]] [files]

Description
       The  command  sorts lines of the named files together and writes the result on the standard output.  The standard input is read if a hyphen
       (-) is used as a file name or if no input files are named.

       Comparisons are based on one or more sort keys extracted from each line of input.  By default, there is one  sort  key,	the  entire  input
       line,  and  ordering is determined by the collating sequence specified by the LC_COLLATE locale. The LC_COLLATE locale is controlled by the
       settings of either the LANG or LC_COLLATE environment variables. See for more information.

Options
       The following options alter the default behavior:

       -c   Checks that the input file is sorted according to the ordering rules; gives no output unless the file is out of order.

       -m   Merges only; the input files are already sorted.

       -u   Suppresses all but one in each set of lines having equal keys.

       -ooutput
	    Specifies the name of an output file to use instead of the standard output.  The file may be the same as one of  the  inputs.   Blanks
	    between -o and output are optional.

       -ykmem
	    Specifies  the  number  of	kilobytes  of  memory  to use when sorting a file.  If this option is omitted, sort5 begins using a system
	    default memory size, and continues to use more space as needed.  If kmem is specified, sort5 starts using that number of kilobytes	of
	    memory.   If  the administrative minimum or maximum is violated, the value of the corresponding minimum or maximum is used.  Thus, -y0
	    is guaranteed to start with minimum memory.  By convention, -y (with no argument) starts with maximum memory.

       -zrecsz
	    Records the size of the longest line read in the sort phase so buffers can be allocated during the merge phase.  If the sort phase	is
	    omitted using either the -c or -m options, a system default size is used.  Lines longer than the buffer size cause to terminate abnor-
	    mally.  Supplying the actual number of bytes (or some larger value) in the longest line to be merged prevents abnormal termination.

       -X   Sorts using tags. Upon input each key is converted to a tag value which is sorted efficiently. This option makes international sorting
	    faster but it consumes more memory since both key and tag must be stored.

       The following options override the default ordering rules:

       -d   Specifies Dictionary order.  Only letters, digits and blanks (spaces and tabs) are significant in comparisons.

       -f   Folds lower case letters into upper case.

       -i   Ignores characters outside the ASCII range 040-0176 in non-numeric comparisons.

       -n   Sorts  an  initial	numeric  string, consisting of optional blanks, optional minus sign, and zero or more digits with optional decimal
	    point, by arithmetic value.  The -n option implies the -b option, which tells the command to ignore leading  blanks  when  determining
	    the starting and ending positions of a restricted sort key.

       -r   Reverses the sense of comparisons.

       When ordering options appear before restricted sort key specifications, the requested ordering rules are applied globally to all sort keys.
       When attached to a specific sort key (described below), the specified ordering options override all global ordering options for that key.

       The notation +pos1 -pos2 restricts a sort key to one beginning at pos1 and ending at pos2.  The characters at positions pos1 and  pos2  are
       included in the sort key (provided that pos2 does not precede pos1).  A missing -pos2 means the end of the line.

       Specifying  pos1  and pos2 involves the notion of a field, that is a minimal sequence of characters followed by a field separator or a new-
       line.  By default, the first blank of a sequence of blanks acts as the field separator.	The blank can be either a space  or  a	tab.   All
       blanks  in a sequence of blanks are interpreted as a part of the next field; for example, all blanks at the beginning of a line are consid-
       ered to be part of the first field.  The treatment of field separators is altered using the following options:

       -tx  Uses x as the field separator character.  Although it may be included in a sort key, x is not considered part of a field.  Each occur-
	    rence of x is significant (for example, xx delimits an empty field).

       -b   Ignores  leading  blanks  when  determining the starting and ending positions of a restricted sort key.  If the -b option is specified
	    before the first +pos1 argument, it is applied to all +pos1 arguments.  Otherwise, the b flag may be attached  independently  to  each
	    +pos1 or -pos2 argument.

       Pos1  and  pos2	each  have  the form m.n optionally followed by one or more of the flags bdfinr.  A starting position specified by +m.n is
       interpreted to mean the n+1st character in the m+1st field.  A missing .n means .0, indicating the first character of the m+1st field.	If
       the  b  flag  is  in  effect n is counted from the first non-blank in the m+1st field; +m.0b refers to the first non-blank character in the
       m+1st field.

       A last position specified by -m.n is interpreted to mean the nth character (including separators) after the last  character  of	the  m	th
       field.  A missing .n means .0, indicating the last character of the mth field.  If the b flag is in effect n is counted from the last lead-
       ing blank in the m+1st field; -m.1b refers to the first non-blank in the m+1st field.

       When there are multiple sort keys, later keys are compared only after all earlier keys are found to be equal.  Lines that otherwise compare
       equal are ordered with all bytes significant.

Examples
       Sort the contents of infile with the second field as the sort key:

	      sort5 +1 -2 infile

       Sort,  in  reverse  order,  the	contents of infile1 and infile2, placing the output in outfile and using the first character of the second
       field as the sort key:

	      sort5 -r -o outfile +1.0 -1.2 infile1 infile2

       Sort, in reverse order, the contents of infile1 and infile2 using the first non-blank character of the second field as the sort key:

	      sort5 -r +1.0b -1.1b infile1 infile2

       Print the password file sorted by the numeric user ID (the third colon-separated field):

	      sort5 -t: +2n -3 /etc/passwd

       Print the lines of the already sorted file infile, suppressing all but the first occurrence of lines  having  the  same	third  field  (the
       options -um with just one input file make the choice of a unique representative from a set of equal lines predictable):

	      sort5 -um +2 -3 infile

Diagnostics
       Comments  and exits with non-zero status for various trouble conditions (for example, when input lines are too long), and for disorder dis-
       covered under the -c option.

       When the last line of an input file is missing a new-line character, sort5 appends one, prints a warning message, and continues.

Files
       /usr/tmp/stm???

See Also
       comm(1), join(1), uniq(1), setlocale(3int), strcoll(3int)

																	  sort5(1)
All times are GMT -4. The time now is 11:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy