Sponsored Content
Full Discussion: read command
Top Forums Shell Programming and Scripting read command Post 302189606 by COD on Saturday 26th of April 2008 04:49:12 PM
Old 04-26-2008
Nope, its doesn't. The trailing and preceeding spaces are truncated. But if
Quote:
IFS
is set to something like
Quote:
IFS="$"
then the preceeding and trailing spaces can also be taken into account.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

read command

'Morning vmstat 1 1|sed 1,2d|awk '{printf("%s\n",$1)}'|read var echo $var This syntax run on AIX (ksh) but not on linux (bash). I think that problem is the read command, because the following syntax is ok : vmstat 1 1|sed 1,2d|awk '{printf("%s\n",$1)}' Could someone help me! regards... (16 Replies)
Discussion started by: nymus7
16 Replies

2. Shell Programming and Scripting

Regarding read command

Hi all, What does -u option indicates in read command. while read -u var1 do . . done < file.txt (1 Reply)
Discussion started by: krishna_gnv
1 Replies

3. Shell Programming and Scripting

read command in while

hi all iam not able use read command in the while loop in the following program while read line do echo $line echo "enter name" read name echo "your have entered $name" done < work.txt THE READ COMMAND INSIDE THE WHILE LOOP IS NOT WORKING, IS ANY OTHER WAY TO SOLVE THIS... (7 Replies)
Discussion started by: avi.skynet
7 Replies

4. Shell Programming and Scripting

read command

Is there a way to use the READ command and force the user to enter a non-zero length string? If the user enters a zero length string the user input is rejected. code: print "what is the answer: \n" read answer (2 Replies)
Discussion started by: djehresmann
2 Replies

5. UNIX for Dummies Questions & Answers

Read command

Hi everyone, I have problem while writing a shell script for linux (Red Hat). First I need to create a read command. I tried to google this but so far I can't sort this out. I hope you will be able to help me. I have to read a file like this : GESTION_DATA_SET_variable1_variable2 ... (2 Replies)
Discussion started by: Aswex
2 Replies

6. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

7. Shell Programming and Scripting

read command

Hello guys, I am trying to a script that reads from key board and use the entered value in the next step. Example: enter folder name read $folder (i will give work) cd /main/$folder/ pwd it should print /main/work ---------- Post updated at 03:31 PM ----------... (1 Reply)
Discussion started by: sharath24
1 Replies

8. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

9. UNIX for Beginners Questions & Answers

Need help with read command

Is there a way to make the input of the read command (or some similar command that I'm unaware of) not visible, or with an astrix?? An example: #!/bin/bash # Example echo; echo "Who are you??"; read name if ; then echo "Welcome, the terminal is yours."; exit else "Stranger... (2 Replies)
Discussion started by: Huitzilopochtli
2 Replies

10. UNIX for Beginners Questions & Answers

Read command

Trying to use the read command. How do you add a 2nd option? In this example I'd like to offer two options, pre and post. If you answer pre, you get one output but if you answer post, you get another output. echo Is this pre or post? read pre if then echo You have typed pre. fi (6 Replies)
Discussion started by: jimmyf
6 Replies
SHELL-QUOTE(1)						User Contributed Perl Documentation					    SHELL-QUOTE(1)

NAME
shell-quote - quote arguments for safe use, unmodified in a shell command SYNOPSIS
shell-quote [switch]... arg... DESCRIPTION
shell-quote lets you pass arbitrary strings through the shell so that they won't be changed by the shell. This lets you process commands or files with embedded white space or shell globbing characters safely. Here are a few examples. EXAMPLES
ssh preserving args When running a remote command with ssh, ssh doesn't preserve the separate arguments it receives. It just joins them with spaces and passes them to "$SHELL -c". This doesn't work as intended: ssh host touch 'hi there' # fails It creates 2 files, hi and there. Instead, do this: cmd=`shell-quote touch 'hi there'` ssh host "$cmd" This gives you just 1 file, hi there. process find output It's not ordinarily possible to process an arbitrary list of files output by find with a shell script. Anything you put in $IFS to split up the output could legitimately be in a file's name. Here's how you can do it using shell-quote: eval set -- `find -type f -print0 | xargs -0 shell-quote --` debug shell scripts shell-quote is better than echo for debugging shell scripts. debug() { [ -z "$debug" ] || shell-quote "debug:" "$@" } With echo you can't tell the difference between "debug 'foo bar'" and "debug foo bar", but with shell-quote you can. save a command for later shell-quote can be used to build up a shell command to run later. Say you want the user to be able to give you switches for a command you're going to run. If you don't want the switches to be re-evaluated by the shell (which is usually a good idea, else there are things the user can't pass through), you can do something like this: user_switches= while [ $# != 0 ] do case x$1 in x--pass-through) [ $# -gt 1 ] || die "need an argument for $1" user_switches="$user_switches "`shell-quote -- "$2"` shift;; # process other switches esac shift done # later eval "shell-quote some-command $user_switches my args" OPTIONS
--debug Turn debugging on. --help Show the usage message and die. --version Show the version number and exit. AVAILABILITY
The code is licensed under the GNU GPL. Check http://www.argon.org/~roderick/ or CPAN for updated versions. AUTHOR
Roderick Schertler <roderick@argon.org> perl v5.16.3 2010-06-11 SHELL-QUOTE(1)
All times are GMT -4. The time now is 12:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy