Perl or sed command ?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl or sed command ?
# 1  
Old 12-20-2013
Perl or sed command ?

Hi Guys

Am working on a bash script but got stuck, in this line:

32 $configValues['CONFIG_DB_PASS'] = '';

What would be the best command to enter the password between the " Perl or sed ?

Been trying with Perl using this command:

perl -pi -e 's/''/Seattle#1669!/g' /var/www/html/daloradius/library/daloradius.conf.php

Which of course is not working.

Really appreciate any help.
# 2  
Old 12-20-2013
Like so:
 sed "s/''/'password'/" file
32 $configValues['CONFIG_DB_PASS'] = 'password';

This User Gave Thanks to RudiC For This Post:
# 3  
Old 12-20-2013
Hi RudiC thank you for the help, when running command this is what I get:

[root@p1 db]# sed "s/''/'Seattle#1669!'/" /var/www/html/daloradius/library/daloradius.conf.php
-bash: !'/": event not found

Any ideas ?
# 4  
Old 12-20-2013
Hi, you must protect ! , so as \!:
sed "s/''/'Seattle#1669\!'/" /var/www/html/daloradius/library/daloradius.conf.php

This User Gave Thanks to disedorgue For This Post:
# 5  
Old 12-20-2013
Hi disedorgue

That did the trick, thank you for the help.

@ RudiC thank you for the help.
# 6  
Old 12-21-2013
For modifying the source file add the -i option.
Also, ensuring the line has got PASS seems safer.
sed -i "/PASS/ s/''/'Seattle#1669\!'/" /var/www/html/daloradius/library/daloradius.conf.php

sed -i -pe "s/''/'Seattle#1669\!'/ if /PASS/;" /var/www/html/daloradius/library/daloradius.conf.php

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rewrite sed to perl or run sed in perl

I am having trouble re-writing this sed code sed -nr 's/.*del(+)ins(+).*NC_0{4}(+).*g\.(+)_(+).*/\3\t\4\t\5\t\1\t\2/p' C:/Users/cmccabe/Desktop/Python27/out_position.txt > C:/Users/cmccabe/Desktop/Python27/out_parse.txt in perl Basically, what the code does is parse text from two fields... (12 Replies)
Discussion started by: cmccabe
12 Replies

2. Shell Programming and Scripting

Sed/awk/perl command to replace pattern in multiple lines

Hi I know sed and awk has options to give range of line numbers, but I need to replace pattern in specific lines Something like sed -e '1s,14s,26s/pattern/new pattern/' file name Can somebody help me in this.... I am fine with see/awk/perl Thank you in advance (9 Replies)
Discussion started by: dani777
9 Replies

3. Shell Programming and Scripting

Command to remove duplicate lines with perl,sed,awk

Input: hello hello hello hello monkey donkey hello hello drink dance drink Output should be: hello hello monkey donkey drink dance (9 Replies)
Discussion started by: cola
9 Replies

4. Shell Programming and Scripting

Perl & Sed command -- Out of Memory Error

Experts, We used to receive our source files with '~^' as row delimiter. This file contains 2500K records and two of the columns having value in HTML formats within the file. While running the below commands against the file, we are encountering out of memory, could you please help to... (3 Replies)
Discussion started by: srivijay81
3 Replies

5. Shell Programming and Scripting

awk/sed/perl command to delete specific pattern and content above it...

Hi, Below is my input file: Data: 1 Length: 20 Got result. Data: 2 Length: 30 No result. Data: 3 Length: 20 (7 Replies)
Discussion started by: edge_diners
7 Replies

6. Shell Programming and Scripting

sed command in perl script

What is wrong with this line in a perl script? $amc_data = `sed -n '/\/,/\/p' "$config_file"` I ran the above from command line and it works fine from unix command prompt. The code should produce output between the and tags. The config_file is as follows: Sun ... (2 Replies)
Discussion started by: som.nitk
2 Replies

7. Shell Programming and Scripting

Convert Sed command to perl command

Hello, Can any perl experts help me convert my sed string to perl. I am unsuccessful with this. I have to remove this string from html files OAS_AD('Top'); I have come up with this. However the requirement is in perl. for find in $(find . -type f -name "file1.html") ; do cat $find |... (2 Replies)
Discussion started by: abacus
2 Replies

8. Shell Programming and Scripting

Loop with sed command to replace line with sed command in it

Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line. ... (1 Reply)
Discussion started by: cbo0485
1 Replies

9. Shell Programming and Scripting

[Perl] Accessing array elements within a sed command in Perl script

I am trying to use a script to replace the header of each file, whose filename are stored within the array $test, using the sed command within a Perl script as follows: $count = 0; while ( $count < $#test ) { `sed -e 's/BIOGRF 321/BIOGRF 332/g' ${test} > 0`; `cat 0 >... (2 Replies)
Discussion started by: userix
2 Replies

10. UNIX for Dummies Questions & Answers

how to use sed or perl command to find and replace a directory in a file

how to use sed command to find and replace a directory i have a file.. which contains lot of paths ... for eg.. file contains.. /usr/kk/rr/12345/1 /usr/kk/rr/12345/2 /usr/kk/rr/12345/3 /usr/kk/rr/12345/4 /usr/kk/rr/12345/5 /usr/kk/rr/12345/6 /usr/kk/rr/12345/7... (1 Reply)
Discussion started by: wip_vasikaran
1 Replies
Login or Register to Ask a Question