kchinnam,
what we're trying to say is that you need neither a subshell $( ... ) nor the first echo command in this case. This code is more correct and concise:
You need to quote the variable str in order to prevent shell globbing (or some other special character expansion).
I'd recommend the printf builtin command instead of echo for greater portability (and flexibility).
Hi,
I have a variable which has a list of string separated by comma.
for ex ,
Variable=/usr/bin,/usr/smrshbin,/tmp
How can i get the values between the commas separately using shell scripts.Please help me.
Thanks,
Padmini. (6 Replies)
Taking inputs in the script which is space separated and passing this to a function and i have assigned like below
And then when I use for loop for the inputs i got from the user, it is taking only the first argument.
Enter Names : Bala Sundar Sridhar
read names
namesCheck $names
function... (7 Replies)
Hi, i have this text:
X (m) 4917536.9627 4917536.9673 0.0090 -0.0046
Y (m) -815726.1383 -815726.1294 0.0061 -0.0089
Z (m) 3965857.4730 3965857.4840 0.0071 -0.0110
X (m) 4917536.9627 4917537.1411 -0.1784 0.1710
Y (m) -815726.1383 -815726.4859 0.3476 0.3489
Z (m) 3965857.4730... (2 Replies)
Hi
pls help me to get the code:
i have a file in which content is :
2.01304E+11 2.01304E+11 ori 2 01:00
2.01304E+11 2.01304E+11 ori 2 01:02
2.01304E+11 2.01304E+11 ori 3 01:02
2.01304E+11 2.01304E+11 ori 3 ... (7 Replies)
Hi,
I have a large number of files which are written as csv (comma-separated values).
Does anyone know of simple sed/awk command do achieve this?
Thanks!
---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ----------
Guess I asked this too soon. Found the... (0 Replies)
hello experts,
i am retrieving values in variables jobKey and jobName within my shell script. these values are returned to me within braces and i am using following command to remove those braces:
jobKeys=`echo $jobKeys | sed 's:^.\(.*\).$:\1:'`
jobNames=`echo $jobNames | sed... (1 Reply)
Hi
I have been racking my (limited) brains to get this to work without success
I have a file output which is a list of lists - ie a single column of data that is separated by space into sub lists below - I need to both split this so that each list is in a separate column (eg tab or semicolon... (8 Replies)
I have a file containing multiple values, some of them are pipe separated which are to be read as separate values and some of them are single value all are these need to store in variables.
I need to read this file which is an input to my script
Config.txt
file name, first path, second... (7 Replies)
Hi,
I am having a file say list1 with a output like below
jun 12 18:23
may 20 18:23
Now i want to pass the above two values into for loop,I have written a script like this.
#!/bin/bash
a=`cat list1`
for i in $a
do
echo "HI $i"
done
expected output:
HI jun 12 18:23 (3 Replies)
Hello,
I have a file which has the following contents :
thewall............0000000000200000 kmemfreelater......0000000000000000
kmemgcintvl........0000000000000002 kmeminuse..........00000000223411C0
allocated..........0000000029394000 bucket.......... @.F1000A02800C2158
The mentioned... (4 Replies)
Discussion started by: rahul2662
4 Replies
LEARN ABOUT PHP
addslashes
ADDSLASHES(3) 1 ADDSLASHES(3)addslashes - Quote string with slashesSYNOPSIS
string addslashes (string $str)
DESCRIPTION
Returns a string with backslashes before characters that need to be escaped. These characters are single quote ( '), double quote ( "),
backslash ( ) and NUL (the NULL byte).
An example use of addslashes(3) is when you're entering data into string that is evaluated by PHP. For example, O'Reilly is stored in
$str, you need to escape $str. (e.g. eval("echo '".addslashes($str)."';"); )
To escape database parameters, DBMS specific escape function (e.g. mysqli_real_escape_string(3) for MySQL or pg_escape_literal(3),
pg_escape_string(3) for PostgreSQL) should be used for security reasons. DBMSes have differect escape specification for identifiers (e.g.
Table name, field name) than parameters. Some DBMS such as PostgreSQL provides identifier escape function, pg_escape_identifier(3), but not
all DBMS provides identifier escape API. If this is the case, refer to your database system manual for proper escaping method.
If your DBMS doesn't have an escape function and the DBMS uses to escape special chars, you might be able to use this function only when
this escape method is adequate for your database. Please note that use of addslashes(3) for database parameter escaping can be cause of
security issues on most databases.
The PHP directive magic_quotes_gpc was on by default before PHP 5.4, and it essentially ran addslashes(3) on all GET, POST, and COOKIE
data. Do not use addslashes(3) on strings that have already been escaped with magic_quotes_gpc as you'll then do double escaping. The func-
tion get_magic_quotes_gpc(3) may come in handy for checking this.
PARAMETERS
o $str
- The string to be escaped.
RETURN VALUES
Returns the escaped string.
EXAMPLES
Example #1
An addslashes(3) example
<?php
$str = "Is your name O'Reilly?";
// Outputs: Is your name O'Reilly?
echo addslashes($str);
?>
SEE ALSO stripcslashes(3), stripslashes(3), addcslashes(3), htmlspecialchars(3), quotemeta(3), get_magic_quotes_gpc(3).
PHP Documentation Group ADDSLASHES(3)