Sponsored Content
Top Forums Shell Programming and Scripting How to substitute a word in multiple file? Post 303005880 by natraj005 on Tuesday 24th of October 2017 11:06:35 AM
Old 10-24-2017
How to substitute a word in multiple file?

Team,

I want to change below parameter in all the files in a directory,

Check for HOSTNAME=`hostname`
Change to HOSTNAME=localhost

And I tried below but, its not working ☹

Code:
find /tmp -type f -exec sed 's/"HOSTNAME\=\`hostname\`"/"HOSTNAME\=localhost/g'"

Help me if I am missing something ...

Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 10-24-2017 at 12:11 PM.. Reason: Added CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to substitute more than one word in a text file?

well i have this file here: <XML> <pregate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <system_c>HPREGATE</system_c> <trans_c>HSPG</trans_c> <trans_dt>20060105161333</trans_dt> <user_id_m></user_id_m> <func_c>C</func_c> </pregate> </XML> i want to... (2 Replies)
Discussion started by: forevercalz
2 Replies

2. Shell Programming and Scripting

Can a shell script pull the first word (or nth word) off each line of a text file?

Greetings. I am struggling with a shell script to make my life simpler, with a number of practical ways in which it could be used. I want to take a standard text file, and pull the 'n'th word from each line such as the first word from a text file. I'm struggling to see how each line can be... (5 Replies)
Discussion started by: tricky
5 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

AWK Multiple substitute

I want to reformat the following: ID1 ID001 0 0 2 1 GG TC GG CT GG AA AA AG ID2 ID002 0 0 2 2 GG 00 AG CC GG GG TC CC I want to replace only:... (1 Reply)
Discussion started by: genehunter
1 Replies

5. Shell Programming and Scripting

howto substitute word in vi command mode

Hi I'm trying to substitute word "January" with word "March" in my script but in certain lines only. I have couple words containing pattern that I want to substitute e.g. - log.January.1.array - log_January_1_array_1 - log.January.1.array - log_January_1_array_11 Trying to do cmd below... (9 Replies)
Discussion started by: presul
9 Replies

6. Shell Programming and Scripting

Perl: substitute multiple lines

I'd like to do this using Perl command line (sorry no awk, sed, etc.) replace the 3 middle lines in a file by one line: aaa 123 bbb 234 ccc 34567 dd 4567 ee 567 to: aaa 123 AAA ee 567 I tried this but not working: perl -pi -e "s/aaa\ 123\nbbb\ 234\nccc\ 34567/AAA/" file (2 Replies)
Discussion started by: tintin78899
2 Replies

7. Shell Programming and Scripting

removing a word in a multiple file starting at the dot extension

hi I would like to ask if someone knows a command or a script on how to rename a multiple file in the directory starting at the end of the filename or at the .extension( i would like to remove the last 11 character before the extension) for example Below is the result of my command ls inside... (5 Replies)
Discussion started by: jao_madn
5 Replies

8. Shell Programming and Scripting

Substitute one line of multiple files according to another file

I need to make ~96 configure files from a template config file which has hundreds of rows that looks like: template.config: #average insert size avg_ins=1000 ...... other information omitted Those config files are named in sequence from S01.config, S02.config, ... etc with different... (11 Replies)
Discussion started by: yifangt
11 Replies

9. Shell Programming and Scripting

In Vi "sed" substitute word on a specific line

i need to substitute word on a specific line. I was able to do it on command line like below but it is not working in vi. command line like below: sed -e '8s/table_name/schema.table_name/' file_name. in vi table_name and schema are my positional parameters that i pass into the script. ... (5 Replies)
Discussion started by: pimmit22043
5 Replies

10. Shell Programming and Scripting

To substitute multiple variable by their content in a file

Dear All, I would like to instantiate a "pattern file" substituting "variable name" by their content. Saying, we have: 1/ a "pattern file" containing different "variable name", the first character of the "variable name" is "@": $ cat TPTModl.txt DEFINE... (12 Replies)
Discussion started by: dae
12 Replies
dtest(1)							   USER COMMANDS							  dtest(1)

NAME
dtest - simple uDAPL send/receive and RDMA test SYNOPSIS
dtest [-P provider] [-b buf size] [-B burst count][-v] [-c] [-p] [-d] [-s] dtest [-P provider] [-b buf size] [-B burst count][-v] [-c] [-p] [-d] [-h HOSTNAME] DESCRIPTION
dtest is a simple test used to exercise and verify the uDAPL interfaces. At least two instantiations of the test must be run. One acts as the server and the other the client. The server side of the test, once invoked listens for connection requests, until timing out or killed. Upon receipt of a cd connection request, the connection is established, the server and client sides exchange information necessary to per- form RDMA writes and reads. OPTIONS
-P=PROVIDER use PROVIDER to specify uDAPL interface using /etc/dat.conf (default OpenIB-cma) -b=BUFFER_SIZE use buffer size BUFFER_SIZE for RDMA(default 64) -B=BURST_COUNT use busrt count BURST_COUNT for interations (default 10) -v, verbose output(default off) -c, use consumer notification events (default off) -p, use polling (default wait for event) -d, delay in seconds before close (default off) -s, run as server (default - run as server) -h=HOSTNAME use HOSTNAME to specify server hostname or IP address (default - none) EXAMPLES
dtest -P OpenIB-cma -v -s Starts a server process with debug verbosity using provider OpenIB-cma. dtest -P OpenIB-cma -h server1-ib0 Starts a client process, using OpenIB-cma provider to connect to hostname server1-ib0. SEE ALSO
dapltest(1) AUTHORS
Arlin Davis <ardavis@ichips.intel.com> BUGS
uDAPL 1.2 February 23, 2007 dtest(1)
All times are GMT -4. The time now is 11:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy