Sponsored Content
Homework and Emergencies Homework & Coursework Questions Outputting variables on a line Post 302361969 by huckknows on Wednesday 14th of October 2009 02:22:40 PM
Old 10-14-2009
Outputting variables on a line

Stuck on formatting an output. I want to list 6-99 on the screen, looking something like this:

99 98 97 96 95 94 93 92 91 90
89 88 87 86 85 84 83 82 81 80
and so on down to 6.

So far I am only able to print one value per line.

This is what I have

I have defined x as integer x=99 before the loop

then I have a loop to send the output:

until [[ x -eq 5 ]] ; do
print "$x"
x=x-1
done


I was thinking I may need to add another loop within my first loop, I have been messing around but I am just stumped.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cannot print 3 variables on same line

Hi, I have a file containing emails about some issues. Using a bourne shell script, I need to extract the issue number from the URL's contained in the file (all URL's look like this : http://www.openoffice.org/issues/show_bug.cgi?id=1881) and then print out the issue number, status and... (2 Replies)
Discussion started by: Chris Jones
2 Replies

2. Shell Programming and Scripting

sed not outputting last line of input file

I am using sed for a simple substitution (see command syntax below). Everything works fine except that the last line of the input file does not get written to the output file. Has anyone ever seen this and know of way to force the last line to be written? I don't know if it's playing a part in... (3 Replies)
Discussion started by: 2reperry
3 Replies

3. Shell Programming and Scripting

Problem with reading file line-by-line, and outputting to a new file

Hi everyone. I realise this is probably a bit of a noob question, but I'm actually a C# developer working on a legacy system, and can't remember much unix. I want to read from a pipe-delimeted file like formatted thusly: idno|PRODUCT|Name|street town postcode|etc|etc|etc|etc... (4 Replies)
Discussion started by: Darkness Fish
4 Replies

4. AIX

insert a line with variables using sed

Hi, I have to insert a line having variables using sed. But the variables are not getting substituted within sed. Ex: n=2 sed $n' i\ hi' file This works. But the below code does not work. n=2 line=hello sed $n' i\ $line' file The above code inserts '$line' in the 2nd line of the... (9 Replies)
Discussion started by: sugan
9 Replies

5. Shell Programming and Scripting

Place variables at the beginning of each line

Hello all, I am very new to the shell scripting and I hope someone can help me with this. I have thousands of files with certain format of information and I need to do this for all my files. For each file, grab the numbers in the first and second rows and place them in the position 1 and 2... (8 Replies)
Discussion started by: GoldenFire
8 Replies

6. Shell Programming and Scripting

linux shell script to take variables from two different files line by line

Friends I need to have a shell script which will feed variables from two different files line-by-line. For example, I have two files - permission and file_name. Contents of permission is - 644 755 .... contents of file_name /file1 /file2 ..... Now I want 644 permission will be... (4 Replies)
Discussion started by: atanubanerji
4 Replies

7. Shell Programming and Scripting

PRINT TWO VARIABLES IN ONE LINE

my command nawk -F' ' '{for(i=1;i<=NF;i++){if ($i ~ /XX/) print i}}' TOM.bk The output is in two lines as below 12 30 i want the output in one line with comma delimited as below 12,30 the 23 and 79 are column numbers in one line of the file. so i want all the two columns... (1 Reply)
Discussion started by: dealerso
1 Replies

8. Shell Programming and Scripting

Help to process line by line and assign value to variables

Hi, there I have a file with tab and space as field separator. I need to assign values to variables then work with them, line by line. The code I wrote only works when each line has only one word. It doesn't work for the current situation. for line in `cat file.txt`; do ID=`awk '{print... (4 Replies)
Discussion started by: cwzkevin
4 Replies

9. Shell Programming and Scripting

read line by line and calculate the co-presence of variables

Hey guyz, I have a table which shows the presence or absence of my variables (A,B,C,...) in my observations (1,2,3,...) * A B C ... 1 1 0 1 2 1 1 0 3 1 0 0 ... I want to calculate the co-presence of my variables. to have a table shows the pairwise presence of the variables (have... (1 Reply)
Discussion started by: @man
1 Replies

10. Shell Programming and Scripting

Splitting a line in two variables

Hello. The file /etc/fstab contains UUID=957c3295-9944-1593-82e2-2b90dede4312 / ext4 acl,user_xattr 1 1I fill a variable SOME_LINE=$( cat /etc/fstab | grep \/\..*ext4 )I want PART1=>>>>>UUID=957c3295-9944-1593-82e2-2b90dede4312 / ext4 ... (2 Replies)
Discussion started by: jcdole
2 Replies
mhl(1mh)																  mhl(1mh)

Name
       mhl - produce formatted listings of MH messages

Syntax
       mhl [ options ] [ files...  ]

Description
       The command is a program for listing formatted messages, which can be used as a replacement for the default program.

       As  with  each  of the messages specified as arguments (or the standard input) are output.  If more than one message file is specified, you
       are prompted prior to each one, and a <RETURN> or <EOT> begins the output.  <RETURN> clears the screen (if appropriate), and <EOT>, usually
       <CTRL/D>,  suppresses  the  screen clear.  An <INTERRUPT>, usually <CTRL/C>, aborts the current message output, prompting for the next mes-
       sage, if there is one.  A <QUIT>, usually <CTRL/E>, terminates the program without generating a core dump.

       The command operates in two phases: it reads and parses the format file; then it processes each message (file).	During the first phase, an
       internal  description  of  the  format is produced as a structured list.  In the second phase, this list is traversed for each message, and
       message information is output according to the instructions contained in the format file.

   The Form File mhl.format
       The form file contains information controlling screen clearing, screen size, wrap-around control, transparent text, component ordering, and
       component  formatting.	A list of components that should be ignored may also be specified, and some special components are defined to pro-
       vide added functionality.  Message output is in the order specified by the order in the format file.

       Each line of the file has one of the following formats:
	    ;comment
	    :cleartext
	    variable[variable...]
	    component:[variable...]
       A line beginning with a semi colon (;) is a comment, and is ignored.  A line beginning with a colon  (:)  is  clear  text,  and	is  output
       exactly	as  it	is.  A line containing only a colon (:) produces a blank line in the output.  A line beginning with component: defines the
       format for the specified component.  Remaining lines define the global environment.  Examples of these are given below, together  with  the
       system default form file.

       If variables or arguments follow a component, they apply only to that component; otherwise, their effect is global.  Since the whole format
       is parsed before any output processing, the last global switch setting for a variable applies to the whole message, provided that the vari-
       able  is  used  in  a global context (bell, clearscreen, width, length).  All of the current variables and their arguments are shown in the
       following table:

       ------------------------------------------------------------------
       Variable 	Type	   Semantics
       ------------------------------------------------------------------
       width		integer    screen width or component width
       length		integer    screen length or component length
       offset		integer    positions to indent the component
       overflowtext	string	   text to use at the beginning of an
				   overflow line
       overflowoffset	integer    positions to indent overflow lines
       compwidth	integer    positions to indent component text
				   after the first line is output
       uppercase	flag	   output text of this component in all
				   upper case
       nouppercase	flag	   do not use uppercase
       clearscreen	flag/G	   clear the screen prior to each page
       noclearscreen	flag/G	   do not clear the screen
       bell		flag/G	   ring the bell at the end of each page
       nobell		flag/G	   disable bell
       component	string/L   name to use instead of component for
				   this component
       nocomponent	flag	   do not output component: for this
				   component
       center		flag	   center component on line (works for

				   one-line components only)
       nocenter 	flag	   do not center
       leftadjust	flag	   strip off leading white-space on each
				   line of text
       noleftadjust	flag	   do not leftadjust
       compress 	flag	   change newlines in text to spaces
       nocompress	flag	   do not compress
       formatfield	string	   format string for this component
       addrfield	flag	   field contains addresses
       datefield	flag	   field contains dates
       ------------------------------------------------------------------

       To specify the value of integer-valued and string-valued variables, follow their name with an equals-sign (=) and the value.   Integer-val-
       ued  variables  are given decimal values, while string-valued variables are given arbitrary text bracketed by double-quotes.  If a value is
       suffixed by /G or /L, then its value is useful in a global-only or local-only context (respectively).  A line of the form:
	   ignores=component,...
       specifies a list of components which are never output.

       The component MessageName outputs the actual message name (file name) preceded by the folder name if one is specified or found in the envi-
       ronment.  The format is identical to that produced by the -header option to

       The  component Extras outputs all of the components of the message which were not matched by explicit components, or included in the ignore
       list.  If this component is not specified, an ignore list is not needed since all non-specified components are ignored.

       If -nocomponent is not specified, then the component name is output as it appears in the format file.

       The variable formatfield specifies a format string; see The variables addrfield and datefield, which are mutually  exclusive,  control  the
       interpretation of the escapes.

       By  default,  does  not apply any formatting string to fields containing address or dates; see for a list of these fields.  This results in
       faster operation since must parse both addresses and dates in order to apply a format string to them.  If desired, can be given	a  default
       format  string  for either address or date fields, but not both.  To do this, on a global line specify either the variable addrfield or the
       variable datefield, along with the variable formatfield.

Options
       -bell
       -nobell	 Tells to ring the terminal bell at the end of each page.  This is the default behavior.  You  can  suppress  this  by	using  the
		 -nobell option.

		 This  option  takes  effect  only if the profile entry is defined but empty, and if is outputting to a terminal.  If the entry is
		 defined and non-empty, and is outputting to a terminal, then causes the to be placed between the terminal and	and  the  switches
		 are ignored.

       -clear
       -noclear  Tells	to  clear the screen at the end of each page, or output a formfeed after each message.	You can suppress this by using the
		 -noclear option.  The default behavior is -noclear.

		 This option takes effect only if the profile entry is defined but empty, and if is outputting to a terminal.  If the entry in the
		 user's  is  defined and non-empty, and is outputting to a terminal, then causes the program to be placed between the terminal and
		 and the options are ignored.

		 If the -clear option is used and the output of is directed to a terminal, then consults the $TERM and $TERMCAP environment  vari-
		 ables	to determine your terminal type in order to find out how to clear the screen.  If the -clear switch is used and the output
		 of is not directed to a terminal (if, for example, it is directed to a pipe or a file), then sends a formfeed after each message.

       -folder +foldername
		 Sets the folder name.	This is used by components in the form file to output the message name.  If you do not	use  this  option,
		 consults the environmental variable $mhfolder.

       -form formfile
		 Specifies  the format file used.  If this option is not given, searches in your Mail directory for a file called or, if this file
		 does not exist, it uses the system default file

       -help	 Prints a list of the valid options to this command.

       -length lines
		 Sets the screen length.  This defaults to the value indicated by if appropriate; otherwise, it defaults to 40.

       -width columns
		 Sets the screen width.  This defaults to the value indicated by if appropriate; otherwise, it defaults to 80.

       -moreproc program
       -nomoreproc
		 Overrides the default program.  Note that never starts a if invoked on a hardcopy terminal.

       The defaults for this command are:

	      -bell
	      -noclear
	      -length 40
	      -width 80

Examples
       The first example gives a typical line of a form file:
       width=80,length=40,clearscreen,overflowtext="***",overflowoffset=5
       The first two elements define the screen width to be 80 characters, and the screen length to be 40 lines.  The next  element,  clearscreen,
       specifies that the screen should be cleared prior to each page.	The next element, overflowoffset=5, states that that the overflow indenta-
       tion is 5.  The final element, overflowtext="***", specifies that overflow text should be flagged with three asterisks.

       The system default form file, is:
       : -- using template mhl.format - -
       overflowtext="***",overflowoffset=5
       leftadjust,compwidth=9
       ignores=msid,msgid,message-id,received
       Date:formatfield="%<(nodate{text})%{text}%|%(pretty{text})%>"
       To:
       cc:
       :
       From:
       Subject:
       :
       extras:nocomponent
       :
       body:nocomponent,overflowtext=,overflowoffset=0,noleftadjust

Profile Components
       Path:	   To determine your Mail directory
       moreproc:   Program to use as interactive front-end

Files
       The system default form file, used to format message.

       The user-supplied alternate to the system default form file.

       The user profile.

See Also
       more(1), show(1mh), mh_profile(5mh), ap(8mh), dp(8mh)

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