shell


Replace value of filed IF MATCH


I have a file with 3 columns, separated by '\t', looks like:
field_tag field_name field_val
My goal is to replace field_val by field_val_new, if field_tag equals some value, and field_name equals some other value. How can I get this?
You can use just use awk since awk operates on a file on row/column basis:
awk -v OFS='\t' '$1 == "some_tag" && $2 == "some_field" {$3 = "field_val_new"} 1' file
PS: A whitespace including \t is the default field separator in awk.

Related Links

Datadriven shell programming? Suggestions, please
string “Fri Dec 16 16:12:24 CST 2016” to timestamp by shell
Fill Column in CSV with previous value using shell
g++: “command not found” after declaring variables in Bash
Sharing exclusive files to docker instances from host
Splitting a String into Command Line Arguments
Convert a capital case string to camel case using shell script
Update Stock grep?
shell script to login as root into one server without password prompt
Teamcity - setParameter does not permanently store updated value in parameter
Sampling rate 44.1khz for buzzer
atopsar extraction to text file with additional info
Curl Request : response using curl Request is not properly formatted(xml)
In Unix ksh, can I pass variables from one script to another ksh script as parameters in that script call, without making them global with export?
Now I have following code in shell script, can someone help me fix it and understand the code?
Why octave figure closed very soon in emacs

Categories

HOME
azure-stream-analytics
turing-machines
pdfbox
rom
simulink
mips
vxml
vsm
syntaxnet
mql5
little-proxy
heap
appcelerator-studio
github-enterprise
mautic
xcodebuild
nancy
gkturnbasedmatch
dynatrace
scrolltop
google-data-studio
sencha-touch
replication
undertow
roslyn
epsilon
direct3d11
game-theory
bulletphysics
licensing
android-maps
bioinformatics
sqlpackage
panoramas
database-comparison
cart
memory-address
yowsup
processwire
alphabetical
xdocreport
nohup
password-protection
railstutorial.org
mongoose-schema
chef-solo
install.packages
placeholder
knime
android-checkbox
opencmis
flask-restful
textsum
ntvs
bluez
openblas
java-bytecode-asm
gameplay-kit
structuremap4
branch-prediction
pocketsphinx-android
testrail
pytables
stax
latin
myspace
uicolor
observablecollection
pre-build-event
jtwig
sklearn-pandas
ikiwiki
rate-limiting
poppler
ember-cli-rails
haskell-warp
typeconverter
nsurlsessiondatatask
dbaccess
rapidsvn
sql-scripts
create.js
build-script
grails-domain-class
maven-scm
solace-mq
mbunit
ui-select2
intersect
dopostback
cuda-gdb
urlrewriter
opml
feasibility
visualj#
google-wave
complex-event-processing
asynchronous-wcf-call
pbcopy
appliance

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App