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

Efficient way to get unique value from log file
What are the Spacemacs keybindings required to navigate back from the bash shell to the editing windows, and edit the shell window as a buffer?
how is cat < file1.txt file2.txt interpreted?
Count number of semicolon in single cote
Vim Shell Command Confusion
Git bash for windows runs wrong version of python using “python” command
Command prompt keeps disappearing
Variable not working in shell script
How to set PIG_HEAPSIZE value in a shell script triggering a pig job
Issue connecting to JBoss CLI from shell script
find command exec {} matching folder empty - Fish shell
How exclude files that have been processed already
Korn shell, fc command and a notation I don't understand
Cannot get if statement to work
The exponential distribution didn't show up in the shell
how to map and compare filename in shell script

Categories

HOME
uml
beautifulsoup
kentico
gridview
prism
spark-streaming
apache-flink
jmeter
datastore
3d
toolbox
obfuscation
jelastic
shiro
vscode-extensions
rendering
opendj
spring-data-mongodb
nsbundle
permissions
accessibility
little-proxy
plist
mod-security
x-cart
naivebayes
libusb
feathersjs
fileserver
swagger-2.0
solrcloud
symbols
squashfs
systemtime
imageresizer
aggregation
monit
beta
ckfinder
moses
flooding
left-join
database-comparison
testbed
rselenium
jett
biztalk-rule-engine
getpixel
fiware-cygnus
magento-1.9.2.4
metaprogramming
demo
google-data-api
setup.py
numberpicker
tasm
ssrs-2014
ntvs
bluez
edit
rackspace-cloud
universal-analytics
shinobi
smartfoxserver
ziparchive
segment-io
file-uri
resourcemanager
scaffolding
clipboard.js
qiime
deep
cda
inf
concurrentmodification
boomerang
grgit
file-move
pypiserver
zen-cart
binomial-theorem
text-search
sql-server-data-tools
typeconverter
git-ftp
bufferedinputstream
umlgraph
cosine-similarity
contrast
winginx
websphere-esb
openargs
eclipse-kepler
artemis
embedded-fonts
code-duplication
mbunit
node-blade
epiceditor
onload-event
mkv
nokia-s40
qtconcurrent
xcode3.2
correlated-subquery
cuda-gdb
subproject
apache-whirr
google-maps-mobile
filemerge
catransform3d
http-daemon
cruisecontrol.rb
ajax-polling
echo3
interop-domino
wysiwym
mathematical-typesetting

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