Sponsored Content
Top Forums Shell Programming and Scripting In Vi "sed" substitute word on a specific line Post 302960018 by pimmit22043 on Monday 9th of November 2015 02:45:02 PM
Old 11-09-2015
shell script positional parameters have to be inside double quotes and singe quotes when using the sed.

below is code:

Code:
schema_name=1
table_name=2

sed -e '8s/'"$table_name"'/"$schema_name"'.'"$table_name"'/' input_file

Smilie

Last edited by Don Cragun; 11-09-2015 at 04:25 PM.. Reason: Add COE tags again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed substitute / for \ : error "Function can not be parsed"

Hello all, I have a weird issue when trying to substitute the slashes into backslashes. If I execute this on the command-line (bash / ksh) I get the path correctly translated with backslashes instead of slashes. > echo $PWD | sed 's/\//\\/g' However, when I put this in my script to... (3 Replies)
Discussion started by: candyflip2000
3 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Shell Programming and Scripting

Can "sed" substitute word on a specific line?

Hello experts, I know line number of the word I want to replace. Can "sed" substitute word on a specific line? As well, can sed substitute words inside a specific patten. ex. <word>lalala</word> #replace anything between <word> and </word> minifish (2 Replies)
Discussion started by: minifish
2 Replies

4. Shell Programming and Scripting

How to substitute "\" by "\/" using SED?

Input: a/b/c Output required: a\/b\/c This does not work: sed s/'\/'/'\//'/g (6 Replies)
Discussion started by: indianjassi
6 Replies

5. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

6. Shell Programming and Scripting

How do I grep with sed and substitute a "#" on that line

Hey all, I am trying to disable a certain cronjob before I run a backup. I want to be able to add/remove a "#" from the beginning on the crontab line it is located on. Here is the crontab: 46 11 * * * /etc/webmin/cron/tempdelete.pl @daily /etc/webmin/time/sync.pl */5 * * * *... (4 Replies)
Discussion started by: eg mike
4 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

10. Shell Programming and Scripting

Add the word "prefix" to beginning of line using sed

SUSE linux bash shell this works test -d /tmpp && echo "directory exists" || echo "directory doesn't exists" |sed -e "s/^/prefix /" prefix directory doesn't exists but why doesn't this work? test -d /tmp && echo "directory exists" || echo "directory doesn't exists" |sed -e... (3 Replies)
Discussion started by: snoman1
3 Replies
PG_CONVERT(3)															     PG_CONVERT(3)

pg_convert - Convert associative array values into suitable for SQL statement

SYNOPSIS
array pg_convert (resource $connection, string $table_name, array $assoc_array, [int $options]) DESCRIPTION
pg_convert(3) checks and converts the values in $assoc_array into suitable values for use in an SQL statement. Precondition for pg_con- vert(3) is the existence of a table $table_name which has at least as many columns as $assoc_array has elements. The fieldnames in $ta- ble_name must match the indices in $assoc_array and the corresponding datatypes must be compatible. Returns an array with the converted values on success, FALSE otherwise. Note If there are boolean fields in $table_name don't use the constant TRUE in $assoc_array. It will be converted to the string 'TRUE' which is no valid entry for boolean fields in PostgreSQL. Use one of t, true, 1, y, yes instead. Warning This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk. PARAMETERS
o $connection - PostgreSQL database connection resource. o $table_name - Name of the table against which to convert types. o $assoc_array - Data to be converted. o $options - Any number of PGSQL_CONV_IGNORE_DEFAULT, PGSQL_CONV_FORCE_NULL or PGSQL_CONV_IGNORE_NOT_NULL, combined. RETURN VALUES
An array of converted values, or FALSE on error. EXAMPLES
Example #1 pg_convert(3) example <?php $dbconn = pg_connect('dbname=foo'); $tmp = array( 'author' => 'Joe Thackery', 'year' => 2005, 'title' => 'My Life, by Joe Thackery' ); $vals = pg_convert($dbconn, 'authors', $tmp); ?> SEE ALSO
pg_meta_data(3). PHP Documentation Group PG_CONVERT(3)
All times are GMT -4. The time now is 10:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy