Sponsored Content
Top Forums Shell Programming and Scripting awk search and replace and overwrite file Post 302384479 by radoulov on Tuesday 5th of January 2010 12:37:03 PM
Old 01-05-2010
With AWK you'll need something like this:

Code:
awk '{gsub("hello", "bye")}1' test.dat > test.dat_tmp && 
  mv test.dat_tmp test.dat

or this (not recommended):

Code:
{ rm test.dat && 
    awk '{gsub("hello", "bye")}1' > test.dat
  } < test.dat

I would use Perl:

Code:
perl -i -pe's/hello/bye/g' test.dat

This User Gave Thanks to radoulov For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and replace using awk

Dear All, I want to search and replace the text in file using awk. but facing hard luck in that. Please help me out!!!! > grep Abc.De.ync.rate /tmp/sdosanjh.txt Abc.De.ync.rate 6 write Now, I want to replace the "6" with value say "2". I... (5 Replies)
Discussion started by: sdosanjh
5 Replies

2. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

3. Shell Programming and Scripting

Search and Replace using awk

Hi, I am really confused with this problem that I am facing . I have a file that contains entries in the form : option1 Value1 option2 Value2 option3 Value3 option4 Value4 . . . I want to search for the keyword "option4" and replace "value4" by another value, say "value5". My main... (2 Replies)
Discussion started by: harry0812
2 Replies

4. Shell Programming and Scripting

Search and replace in xml file using awk..

Hi All, I have xml file,i am tring to use awk to search pattern as: <Password>x</Password> and Replace with: <Password>y</Password> please any one can help to solve this using awk and awk only. (4 Replies)
Discussion started by: islam2666
4 Replies

5. Shell Programming and Scripting

search and replace with AWK

Suchen und Ersetzen mit AWK hello, i'm not good in scripting and asking for your help. With this script i change some text parts in diffent datafiles. It works without problems, but i need to get some informations about what changes in wich datafiles happend. This could be in character of a... (3 Replies)
Discussion started by: ruffi
3 Replies

6. Shell Programming and Scripting

Find ,replace and overwrite from master and sub dir

Hello experts, Can someone please help me handling the below situation. I have files in multiple directories as below. /data/input/A.txt /data/input/a1.txt /data/input/adhoc/b.txt /data/input/adhoc/b1.txt /data/input/adhoc/temp/c.txt /data/input/adhoc/temp/d.txt where some of... (3 Replies)
Discussion started by: pasupuleti81
3 Replies

7. Shell Programming and Scripting

text file search and replace with awk

hello all greeting for the day i have a text file as the following text.xml abcd<FIELD>123.456</FIELD>efgh i need to replace the value between <FIELD> and </FIELD> by using awk command. please throw some light on this. thank you very very much Erik (5 Replies)
Discussion started by: erikshek
5 Replies

8. Shell Programming and Scripting

awk search/replace specific field, using variables for regexp & subsitution then overwrite file

Hello, I'm trying the solve the following problem. I have a file which I intend to use as a csv called master.csv The columns are separated by commas. I want to change the text on a specific row in either column 3,4,5 or 6 from xxx to yyy depending upon if column 1 matches a specified pattern.... (3 Replies)
Discussion started by: cyphex
3 Replies

9. Shell Programming and Scripting

Search and replace from file in awk using a 16 bit text file

Hello, Some time ago a helpful awk file was provided on the forum which I give below: NR==FNR{A=$0;next}{for(j in A){split(A,P,"=");for(i=1;i<=NF;i++){if($i==P){$i=P}}}}1 While it works beautifully on English and Latin characters i.e. within the ASCII range of 127, the moment a character beyond... (6 Replies)
Discussion started by: gimley
6 Replies

10. Shell Programming and Scripting

Search and replace with awk

Hi Shell Tigers, I am trying to acheive search and replace strings within a setup file. Help much appreciated. test.setup ORACLE_HOME=/oracle/product/11.0.0/home01 PATH1=/perm_loc/3222/FTP/cfg1 PATH2=/perm_loc/3222/FTP/cfg2/bin PATH3=/perm_loc/3222/FTP/cfg3/bin So... (3 Replies)
Discussion started by: jville
3 Replies
ARP2ETHERS(8)						      System Manager's Manual						     ARP2ETHERS(8)

NAME
arp2ethers - convert arpwatch address database to ethers file format SYNOPSIS
arp2ethers [ arp.dat file ] DESCRIPTION
arp2ethers converts the file /var/lib/arpwatch/arp.dat (or the file specified on the command line) into ethers(5) format on stdout. Usu- ally arp.dat is an ethernet/ip database file generated by arpwatch(8). The arpwatch daemon in Debian will create different arp.dat depend- ing on its configuration. All of them will be available at /var/lib/arpwatch/. FILES
/var/lib/arpwatch - default directory for arp.dat arp.dat - ethernet/ip address database SEE ALSO
arpwatch(8), ethers(5), rarp(8), arp(8), BUGS
Please send bug reports to arpwatch@ee.lbl.gov. AUTHORS
Original version by Craig Leres of the Lawrence Berkeley National Laboratory Network Research Group, University of California, Berkeley, CA. Modified for the Debian Project by Peter Kelemen, with additions from Erik Warmelink. The current version is available via anonymous ftp: ftp://ftp.ee.lbl.gov/arpwatch.tar.gz This manual page was contributed by Hugo Graumann. ARP2ETHERS(8)
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy