Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Can someone please explain why we need to set ORS in below awk code? Post 303029051 by Scrutinizer on Sunday 20th of January 2019 02:03:48 AM
Old 01-20-2019
Hi, the default ORS (output record separator) is set to '\n' . If it were left to its default value, then the output of each print command would appear on a different line, whereas the intention appears to be to print al fields on the same line, but in reverse order, separated by two spaces.


--
The creator of the script could have accomplished the same using printf, which is more intended for this purpose and then ORS would not need to be set:

Code:
awk '{for(i=NF;i>0;i--) printf "%s  " $i; print ""}'


Last edited by Scrutinizer; 01-20-2019 at 03:20 AM.. Reason: Added empty string to the print command
This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

could someone explain this code

hey peeps could someone explain what this part of the code means: 'if echo $* | grep -q' $i '|| thanks tHe_nEw_GuY (2 Replies)
Discussion started by: the_new_guy
2 Replies

2. Shell Programming and Scripting

rs and ors in gawk ...????

:D dear members I have a good knowledge of gawk and seem to do quite well with it.. but I have never understood what the use of the rs and ors are for or how they are used.. i am thinking they are for seperating lines and paragraphs but i have absolutely no idea how to make it work, if that is what... (2 Replies)
Discussion started by: moxxx68
2 Replies

3. UNIX for Advanced & Expert Users

explain the code

Hi , Can anyone explains what does the below highlighted statements means: # Set environment variables . ${0%/*}/wrkenv.sh jobName_sh=${0##*/} jobName=${jobName_sh%.*} Thanks, Sri (1 Reply)
Discussion started by: srilaxmi
1 Replies

4. Shell Programming and Scripting

Can any one explain what this code will do

ccc_con,CCC_CON,0 Above is the input for this code #!/usr/bin/bash my_path=`dirname $0` T_table=$1 S_table=$2 P_table=$3 #Star new code while read ${my_path}/arch_table_list.txt { awk -F "," '{print $1}' ${my_path}/arch_table_list.txt ${S_table} awk -F "," '{print... (1 Reply)
Discussion started by: scorp_rahul23
1 Replies

5. Shell Programming and Scripting

Please explain what this code is doing

Hi, Pls explain me what the below code is doing. specially meaning if -a while calling test function- case $1 in 1) beg_dt=01; end_dt=07 ;; 2) beg_dt=08; end_dt=14 ;; 3) beg_dt=15; end_dt=21 ;; 4) beg_dt=22; end_dt=28 ;; 5) beg_dt=29; end_dt=31 ;; esac test \( `date +%w` -eq $2 -a... (3 Replies)
Discussion started by: sendtoshailesh
3 Replies

6. Programming

SET EXPLAIN ON

Hi, I'm working on INFORMIX4GL, i'm just trying to find out the missing indexes in my db. I think SET EXPLAIN ON would give me some hint on this Do anyone know how to use this? Thanks (1 Reply)
Discussion started by: dvah
1 Replies

7. Shell Programming and Scripting

Please explain what this Awk code is doing

Hi Guys, Please help me, I am new to programming and I don’t understand what some parts of this code are doing. I have comments on the parts I know, please help if my understanding of the code is not correct and also help with parts with questions. awk ' { gsub( ">",... (1 Reply)
Discussion started by: James_Owen
1 Replies

8. UNIX for Dummies Questions & Answers

awk code to process column pairs and find those with more than 1 set of possible values

Hi, I have a very wide dataset with pairs of columns starting from column 7 onwards (see example below). 0 123456 -1 0 0 -9 0 0 1 2 2 2 1 1 1 1 2 2... 0 123457 -1 0 0 -9 1 2 1 1 2 2 0 0 0 0 2 2... 0 123458 -1 0 0 -9 0 0 1 2 2 2 1 1 2 2 1 2... 0 123459 -1 0 0 -9 1 2 0 0 2 2 1 1 1 2 1 1...... (2 Replies)
Discussion started by: kasan0
2 Replies

9. Shell Programming and Scripting

awk RS/ORS error

Hello, I am trying to filter fastq file (in short, every 4 lines to be a record) based on the GC counts (GC-contents) in sequence (i.e. field 2), which is the count % of the G/C chars in the string. The example script is to pick up records with GC contents > 0.6 in the sequence (second field). ... (9 Replies)
Discussion started by: yifangt
9 Replies

10. Shell Programming and Scripting

awk : ORS not to be printed after the last record

Hello Team, here is the code: scripts]# ls /etc/init.d/ | awk 'BEGIN{ORS=" && "} /was.init/ && !/interdependentwas/ && !/NodeAgent/ && !/dmgr/{print "\$\{service_cmd\} "$0 " status"}' 2>/dev/null ${service_cmd} cmserver_was.init status && ${service_cmd} fmserver_was.init status &&... (6 Replies)
Discussion started by: chandana.hs
6 Replies
sccshelp(1)						      General Commands Manual						       sccshelp(1)

NAME
sccshelp - ask for help on SCCS commands SYNOPSIS
[arg]... DESCRIPTION
The command finds information to explain a message from an SCCS command or to explain the use of a SCCS command. Zero or more arguments can be supplied. If no arguments are given, prompts for one: The arguments can be either message numbers (which normally appear in parentheses following messages) or command names, of one of the fol- lowing types: Type 1 Begins with nonnumerics, ends in numerics. The nonnumeric prefix is usually an abbreviation for the program or set of routines which produced the message (e.g., for message 6 from the command). Type 2 Does not contain numerics (as a command, such as Type 3 Is all numeric (e.g., The response of the program is the explanatory information related to the argument, if there is any. You can use to support other commands by means of the file. To do this, create help files in the appropriate format and add the location of the helpfiles to EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text as single- and/or multibyte characters. determines the language in which messages are displayed. If is not specified or is null, it defaults to the value of If is not specified or is null, it defaults to "C" (see lang(5)). If any internationalization variable contains an invalid setting, all internationalization variables default to "C". See environ(5). International Code Set Support Single- and multibyte character code sets are supported. DIAGNOSTICS
When all else fails, try EXAMPLES
If you enter the SCCS command without parameters, you would get the message: If you request help for the command: it displays: If you request help for the error number: it displays: WARNINGS
Only SCCS commands currently use FILES
Directory containing files of message text List of commands supported by sccshelp File containing the locations of help files that are not in the directory sccshelp(1)
All times are GMT -4. The time now is 11:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy