Sponsored Content
Full Discussion: sed A Value In A Column
Top Forums UNIX for Beginners Questions & Answers sed A Value In A Column Post 302995331 by jimmyf on Tuesday 4th of April 2017 03:23:17 PM
Old 04-04-2017
sed A Value In A Column

trying to replace a specific value in a column with sed. this is what I have but can't get it to work, replace dog with kitty if dog is in the 3rd column and bunny in the 1st column if bird is there
Code:
bird lizard fish
bird lizard dog
bird lizard fish

Code:
sed '/bird/s/^/bunny/1;'/dog/s/^/kitty/3' file

trying different iterations but just can't seem to get it to work

this would be the output
Code:
bunny lizard fish
bunny lizard kitty
bunny lizard fish

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Change one column using sed??

Is there way to use sed to change only one occurence in a colon separated line? I would like to change a file from *:*:rex:rex *:*:simon:rex to *:*:rex:mabry *:*:simon:rex (2 Replies)
Discussion started by: rexmabry
2 Replies

2. Shell Programming and Scripting

awk/sed column replace using column header - help

$ cat log.txt Name Age Sex Lcation nfld alias xsd CC 25 M XYZ asx KK Y BB 21 F XAS awe SS N SD 21 M AQW rty SD A How can I replace the column with header "Lcation" with the column with header "alias" and delete the "alias" column? so that the final output will become: Name Age Sex... (10 Replies)
Discussion started by: jkl_jkl
10 Replies

3. Shell Programming and Scripting

Can SED Search By Column?

Hi all, I am trying to search for a keyword in the fourth column of a massive carrot(^) delimited file and unfortunately I cannot use AWK (which would have been ideal). Can SED (or maybe even GREP) perform a search like this? (12 Replies)
Discussion started by: Korn0474
12 Replies

4. UNIX for Dummies Questions & Answers

sed changes by column

Is it possible to make changes with the sed command in a specific column only? If yes, how? If not, how could I do that instead? Thanks! ---------- Post updated at 02:01 PM ---------- Previous update was at 01:39 PM ---------- e.g. Group1 Group2_3_1 1_2_3_4_5_ I would like... (8 Replies)
Discussion started by: danieladna
8 Replies

5. Shell Programming and Scripting

Awk or Sed, fubd match in column, then edit column.

FILE A: 9780743551526,(Abridged) 9780743551779,(Unabridged) 9780743582469,(Abridged) 9780743582483,(Unabridged) 9780743563468,(Abridged) 9780743563475,(Unabridged) FILE B: c3saCandyland 9780743518321 "CANDYLAND" "MCBAIN, ED" 2001 c3sbCandyland 9780743518321 ... (7 Replies)
Discussion started by: glev2005
7 Replies

6. Shell Programming and Scripting

use sed on only column $3 with awk

I am using the command ls -lhB --group-directories-first --no-group --file-type --time-style=+%D $@ | sed 's/AlphaLexman/ALM/g' to replace my username with my initials (to keep the width shorter), but if my username is in the filename such asreport_by_AlphaLexman.txtit becomesreport_by_ALM.txt ... (2 Replies)
Discussion started by: AlphaLexman
2 Replies

7. UNIX for Dummies Questions & Answers

Printing a particular column using SED

Hi, i want to display only the particular column using SED command. For example, ps -ef|grep ash |sed -n '1p'|cut -d ' ' -f2   this gives 29067 ps -ef|grep ash |sed -n '1p'|awk '{print $2}'    this also gives the same  in the same way i need the solution using sed. Please... (4 Replies)
Discussion started by: pandeesh
4 Replies

8. Shell Programming and Scripting

awk or sed: change the color of a column w/o screwing up column spacing

Hey folks. I wrote a little awk script that summarizes /proc/net/dev info and then pipes it to the nix column command to set up column spacing appropriately. Here's some example output: Iface RxMBytes RxPackets RxErrs RxDrop TxMBytes TxPackets TxErrs TxDrop bond0 9 83830... (3 Replies)
Discussion started by: ryran
3 Replies

9. Shell Programming and Scripting

Solution for replacement of 4th column with 3rd column in a file using awk/sed preserving delimters

input "A","B","C,D","E","F" "S","T","U,V","W","X" "AA","BB","CC,DD","EEEE","FFF" required output: "A","B","C,D","C,D","F" "S", T","U,V","U,V","X" "AA","BB","CC,DD","CC,DD","FFF" tried using awk but double quotes not preserving for every field. any help to solve this is much... (5 Replies)
Discussion started by: khblts
5 Replies

10. UNIX for Beginners Questions & Answers

Awk/sed summation of one column based on some entry in first column

Hi All , I am having an input file as stated below Input file 6 ddk/djhdj/djhdj/Q 10 0.5 dhd/jdjd.djd.nd/QB 01 0.5 hdhd/jd/jd/jdj/Q 10 0.5 512 hd/hdh/gdh/Q 01 0.5 jdjd/jd/ud/j/QB 10 0.5 HD/jsj/djd/Q 01 0.5 71 hdh/jjd/dj/jd/Q 10 0.5 ... (5 Replies)
Discussion started by: kshitij
5 Replies
jumpnbump(6)							   Games Manual 						      jumpnbump(6)

NAME
jumpnbump - Cute multiplayer platform game with bunnies SYNOPSIS
jumpnbump [ options... ] jumpnbump-menu DESCRIPTION
You, as a bunny, have to jump on your opponents to make them explode. It's a true multiplayer game, you can't play this alone. It has net- work support. Use the jumpnbump-menu command to launch a graphical menu allowing you to select the level and set any command line parameter. OPTIONS
-h Print help. -v Print version. -dat levelname Load levelname and use it as the level for this game. -server playercount Start as server waiting for players. -connect hostname Connect (using a network) to another person running jump'n'bump on hostname. -player num Set main player to num (0-3). Needed for networking. -fireworks Run the program in "screensaver" mode. This is useful with -fullscreen. -fullscreen Run jump'n'bump in fullscreen mode. -nosound Play without sound. -nogore Play without blood. -noflies Disable flies. -mirror Play with mirrored level. -scaleup Play with doubled resolution (800x512). -musicnosound Play with music but without sound. USAGE
The goal of the game is to jump on the other players. Each rabbit has three control keys. Player 1 (Dott) Left - Left Right - Right Jump - Up Player 2 (Jiffy) Left - A Right - D Jump - W Player 3 (Fizz) Left - J Right - L Jump - I Player 4 (Mijji) Left - 4 Right - 5 Jump - 8 In the game Turn on/off computer play (AI) of bunny 1 - 1 Turn on/off computer play (AI) of bunny 2 - 2 Turn on/off computer play (AI) of bunny 3 - 3 Turn on/off computer play (AI) of bunny 4 - 4 SECRETS
You can type these while in the game jetpack - you can fly pogostick - the bunnies keep jumping bunniesinspace - gravity is lower, you can jump higher lordoftheflies - the flies are attracted bloodisthickerthanwater - water turns to blood ADD LEVELS
You can add levels in ~/.jumpnbump/levels directory (create it if necessary). To see the added level, you have to restart jumpnbump-menu. The extension name for level is ".dat". CREATE LEVELS
There are two programs in /usr/lib/jumpnbump to help you make your own levels: pack and unpack. pack /usr/lib/jumpnbump/pack -o /tmp/newlevel.dat <file1> <file2> <file3> ... or you can just put all the files in a dir, cd to that dir and do /usr/lib/jumpnbump/pack -o /tmp/newlevel.dat * and it will put all the files in the current dir inside the packfile. Don't try things like pack -o stuff.dat ../file.c because it will add ../file.c as the filename in the packfile, which won't work. unpack /usr/lib/jumpnbump/unpack level.dat will unpack it in the current directory. gobpack With gobpack you can convert .gob files (which are sprites, described in /usr/share/doc/jumpnbump/gob.txt) into .pcx files which you can edit with The Gimp for example, then convert back to a .gob and use it in your own level. /usr/lib/jumpnbump/gobpack -u font menu.pcx will unpack font.gob using the color palette from menu.pcx and write the files font.pcx font.txt. The other gob files should use level.pcx for the correct palette. /usr/lib/jumpnbump/gobpack font will generate font.gob from font.pcx and the specifications in font.txt. The .pcx files should be resaved with another program, as they are not packed and are thus very large. AUTHORS
Chuck Mason <cemason@users.sourceforge.net>, Jon Atkins <jcatki@home.com>, Philippe Brochard <phil.brochard@wanadoo.fr>, Gurkan Sengun <tarzeau@space.ch>, and "timecop" <timecop@japan.co.jp> are the authors of jump'n'bump. This program is a UNIX port of the old DOS game by brainchilddesign. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. This manual page was written by Joe Wreschnig <piman@sacredchao.net>, for the Debian GNU/Linux system (but may be used by others). June 4th, 2006 jumpnbump(6)
All times are GMT -4. The time now is 01:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy