You can also use
Please note that you need to enter the larger number first if you want your test to succeed (which may not be what you desire) Also note that it is good practice to double quote variable expansions to be safe from surprises like embedded spaces (not applicable in this case of just numbers)
#!/usr/bin/sh
echo "Enter reason:"
echo "> \c"
read $reason
$reason >> access.log
This doesnt work for me. Can someone tell me how I would read the input from what the person types, and then append that to the log file?
Regards (2 Replies)
Hi guys ,
As you know normally ' read ' statement waits
for the user to press enter and then terminates
the input .............
Can anyone of u tell me how do i read a
single character from input without waiting
for the user to press enter ................
Thanks,
Nagesh. (1 Reply)
how do we read input from a user
e.g i want to ask a user to enter 6 sets of numbers
how do i control information from the user?
i have this.......
#!/bin/bash
echo "Please enter six numbers"
read number
echo $number >> file1
but this stops after the first number..how can i... (2 Replies)
I am trying to read input for a C program (that expects input from the user) from a file using the shell command:
progname < filename
but it seems that the program considers the char '<'
as the first input, hence causing an "error" in my program.
I checked it with another program and it... (2 Replies)
Hi guys,
I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help.
I have 2 input files (example given below)
Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Okay, so I've looked on here and found some similar things, but not exactly what I am looking for. I am working on creating a script that can back up some files, based on the contents of another file - the configuration file.
First file contains the files to back up - we'll call this... (1 Reply)
I am trying to edit a file in shell script using sed. I need to get the input from command line
suppose
script.sh
sed"/s place=/place=california/g" > /root/user/mark.txt
echo " place changed "
the above code searches for string place in the file mark.txt and replaces with place=... (5 Replies)
Hello,
I am new to scripting.
How do I read multiple lines from the command line?
I know read reads one line, but if I have to read multiple lines, how should I do?
Thanks,
Prasanna (4 Replies)
So, I am new to shell scripting and have a few problems.
I know how to read from standard input but I do not know how to really compare it to say, a character. I am trying to compare it to a character and anything exceeding just a character, the user will get an output message, but the program... (7 Replies)
echo "Enter the Value : "
read value
sed '1s:\(.\{6\}\)\(.\{4\}\):\1'$value':' flextran$RUN_DATE-completed.txt > temp.txt
mv temp.txt flextran$RUN_DATE-completed.txt
on the run time after entering the input value it waits for keystroke and the values is not input to the function
The output... (4 Replies)
Discussion started by: rammm
4 Replies
LEARN ABOUT OSF1
read
read(1) General Commands Manual read(1)NAME
read - Reads a line from standard input
SYNOPSIS
read [-r] var...
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
read: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Do not treat a backslash character in any special way. Consider each backslash to be part of the input line.
Note
The -r option is included to enable read to subsume the purpose of the obsolete line utility.
OPERANDS
The name of an existing or non-existing shell variable.
DESCRIPTION
The read utility reads a single line from standard input.
By default, unless the -r option is specified, backslash () acts as an escape character. If standard input is a terminal device and the
invoking shell is interactive, read prompts for a continuation line in the following cases: The shell reads an input line ending with a
backslash, unless the -r option is specified. A here-document is not terminated after a newline character is entered.
The line is split into fields as in the shell (see the sh(1) reference page); the first field is assigned to the first variable var, the
second field to the second variable var, and so forth. If there are fewer var parameters specified than there are fields, the leftover
fields and their intervening separators are assigned to the last var. If there are fewer fields than vars, the remaining vars are set to
empty strings.
The setting of variables specified by the var parameters affects the current shell execution environment. If read is called in a subshell
or separate utility execution environment, such as one of the following, it does not affect the shell variables in the caller's environ-
ment:
(read foo) nohup read ... find . -exec read ... ;
NOTES
The -r option is included to enable read to subsume the purpose of the obsolete line utility.
RESTRICTIONS
The results are undefined if an end-of-file is detected following a backslash at the end of a line when -r is not specified.
EXIT STATUS
The following exit values are returned: Successful completion. End-of-file was detected or an error occurred.
EXAMPLES
The following command prints a file with the first field of each line moved to the end of the line:
while read -r xx yy do
printf "%s %s
" "$yy" "$xx" done < input_file
ENVIRONMENT VARIABLES
The following environment variables affect the execution of read: Determines the internal field separators used to delimit fields. Pro-
vides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value
from the default locale is used. If any of the internationalization variables contain an invalid setting, the utility behaves as if none
of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization vari-
ables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed
to multibyte characters in arguments). Determines the locale used to affect the format and contents of diagnostic messages written to
standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. Provides the prompt string that an
interactive shell will write to standard error when a line ending with a backslash is read and the -r option was not specified, or if a
here-document is not terminated after a newline character is entered.
SEE ALSO
Commands: line(1)
Functions: fread(3)
Standards: standards(5)read(1)