The shell peeks inside double quoted strings and processes stuff like variables and command substitution. During this inside peek, a backslash may be treated specially if it is followed one of these 4 characters: $`\" In other words, inside double quotes a backslash is used only to turn off the few characters that otherwise would be treated specially. So in the line,
somecommand "\n"
the shell treats the backslash as just a literal character since it is not followed by a character to interact with. So the command called "somecommand" is run with a single argument of just \n. Now in the case of a line like:
somecommand "\\n"
the first backslash interacts with the second backslash and prevents it from being special. It was destined to not be special anyway since it was not followed by one of the 4 characters it can interact with. But it is fine to explicitly make it non-special with an extra backslash. I usually do this to make the code more obvious.
So in either case, a command is being run with an argument of \n, but now we need to ask what the command will do with that argument. The print command, by default, processes some backslash combos as well. And yes, \n is one. You could use "print -r" or "print -R" to inhibit this.
That is a great reply. echo in tcsh gives very different results, so that was really confusing me!
So to clarify, for
...the shell simply interprets this as literally \n, and sends this to print. For print, a literal \n means newline, so it prints a newline. Yes?
For
the shell treats the first \ as special, because it is followed by a \. The shell takes this to mean that treat the second \ as non-special (which it already is). So the shell once again sends \n to print, and once again we get a newline. Yes?
For
the shell sees the first \ followed by a \, so the first \ is special. The second \ is not special, as it was escaped. The third \ is also not special, as it is followed by a n. So, the shell sends \\n as argument to print. Now print sees \\n as meaning do not treat \n as a newline, and so it prints \n onto the screen. Yes?
(Also, you said the shell only considers \ to be special if it is followed by \ , $ , " or `. So to shell \n does not mean a newline?)
Newline character "\n" not working for ksh in linux AS 3.0
Command :
$echo "Hi\nHi"
$Hi\nHi
$
Expected output :
$echo "Hi\nHi"
Hi
Hi
$
Can some help me on this
Thanks in advance
Sanish. (11 Replies)
Hi All,
In ksh script i'm trying to assign "sqlstmt1" varaible value,
update VAREntryTb set VAR10num = VAR1num * Mltplr where BusD = '$val1' and RunI = 1"`
Hence i wrote below statement, the issue with this is shell is expanding "*" character adn thus subistuting it with the content of my... (6 Replies)
If we assume that each line between the {} container is an XML document then What I want to remove the newline character from all lines within each container to have one XMDL document per line I wrote a bit of sed after trawling the web:
e.g.
#!/bin/sed -nf
H
/}/ {
x
s/\n//g
p... (3 Replies)
Hello:
I am working in bash and am a newbie.
I want to eliminate spaces from strings. Since this is a basic operation, I searched online and implemented the suggestions; however, I am facing a problem here.
I have an input file which looks like this:
abc defghi
jklmno pqrs
tuvw xyzabcd... (8 Replies)
Hello,
I'm trying to create a muliti value shell variable with newlines inside it, So that I can read the values of that variable individually line by line, but KSH seems to be stripping my variable of newlines in LINUX, but UNIX its working fine.
Here's Example :
String =... (3 Replies)
Hi ,
I am working on Linux, with ksh93 installed.
The following statement
echo \\n
just prints
\n on this shell.
However on pdksh
echo \\n gives a blank new line as a output.
What is the correct way of printing a new line character on the ksh93? (4 Replies)
Hi folks,
I've list of LDAP records in this format:
cat cmmac.export.tmp2
dn: deviceId=0a92746a54tbmd34b05758900131136a506,ou=devices,ou=customer,ou=nl,o=upc
cmmac: 00:13:11:36:a5:06
dn: deviceId=0a92746a62pbms4662299650015961cfa23,ou=devices,ou=customer,ou=nl,o=upc
cmmac:... (4 Replies)
Hi,
i made a gnuplot script which accepts a filename as parameter (using gnuplot -e) now i want to run this script from a shell script, the correct command (with a concrete parameter) looks like this:
gnuplot -e 'name="filename.dat;col=2"' gplscript.gpl
my shell script looks like this:
... (4 Replies)
I am trying to echo a variable exactly to a script-
echo "${var1} ${var2} >> output.output
Gives me a blank file.
I would like output.output to basically say:
${var1} ${var2}
I think I need to use a special escape character for variables. Am I right in assuming that, and is it the... (8 Replies)
Discussion started by: jeffs42885
8 Replies
LEARN ABOUT PLAN9
suspend
suspend(1) User Commands suspend(1)NAME
suspend - shell built-in function to halt the current shell
SYNOPSIS
sh
suspend
csh
suspend
ksh
suspend
DESCRIPTION
sh
Stops the execution of the current shell (but not if it is the login shell).
csh
Stop the shell in its tracks, much as if it had been sent a stop signal with ^Z. This is most often used to stop shells started by su.
ksh
Stops the execution of the current shell (but not if it is the login shell).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO csh(1), kill(1), ksh(1), sh(1), su(1M), attributes(5)SunOS 5.10 15 Apr 1994 suspend(1)