Sponsored Content
Top Forums Shell Programming and Scripting oneliner:sing SED on a specific column Post 302214879 by ghostdog74 on Tuesday 15th of July 2008 05:40:36 AM
Old 07-15-2008
Quote:
Originally Posted by chaseeem
is this possible a one liner sed command.

I have a text file ex.
from :
xxx yyy ZZZ /test/devl/aasdasd.log1
xxx yyy ZZZ /test/devl/aasdasd.log2
to :
xxx yyy ZZZ /test/prod/aasdasd.log1
xxx yyy ZZZ /test/prod/aasdasd.log2

and I want to sed only the fourth column

sed 's/devl/prod/g' awk '{print $4}' text
why must it be a sed one liner? anyway for your problem, its easier to work with fields
Code:
awk '$4 ~ /dev/{gsub("devl","prod",$4}1' file

use the more suitable tool for the job
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert a text from a specific row into a specific column using SED or AWK

Hi, I am having trouble converting a text file. I have been working for this whole day now, still i couldn't make it. Here is how the text file looks: _______________________________________________________ DEVICE STATUS INFORMATION FOR LOCATION 1: OPER STATES: Disabled E:Enabled ... (5 Replies)
Discussion started by: Issemael
5 Replies

2. Shell Programming and Scripting

Paste value at specific column using sed

Hi I want to paste some value at specific column in a file using sed. say I want to add "Welcome to UNIX" from column 300 onwards in a file using sed. How to do it . ---------- Post updated at 11:18 AM ---------- Previous update was at 11:09 AM ---------- Adding more information : I... (14 Replies)
Discussion started by: dashing201
14 Replies

3. Shell Programming and Scripting

Can sed be used to insert data at specific column?

I'm trying to use sed to insert data at a specific column, let's say my data looks like this: 0553 1828 0552 1829 0550 1829 0549 1830 0548 1831 what I want is this: timein 0553 timeout 1828 timein 0552 timeout 1829 timein 0550 timeout 1829 timein 0549 timeout 1830 timein 0548... (5 Replies)
Discussion started by: mswartz
5 Replies

4. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

5. UNIX for Dummies Questions & Answers

deleteing duplicate lines sing uniq while ignoring a column

I have a data set that has 4 columns, I want to know if I can delete duplicate lines while ignoring one of the columns, for example 10 chr1 ASF 30 15 chr1 ASF 20 5 chr1 ASF 30 6 chr2 EBC 15 4 chr2 EBC 30 ... I want to know if I can delete duplicate lines while ignoring column 1, so the... (5 Replies)
Discussion started by: japaneseguitars
5 Replies

6. UNIX for Dummies Questions & Answers

Use sed to replace but only in a specific column of the text file

Hi, I would like to use sed to replace NA to x ('s/NA/x/g'), but only in the 5th column of the space delimited text file, nowhere else. How do I go about doing that? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

7. UNIX for Dummies Questions & Answers

Excluding a specific column from sed replacement

Hi, I would like to replace all 0's to 1's throughout my text file. However I do not want column 3 altered. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

8. Shell Programming and Scripting

awk or sed to find specific column from different files

Hi everybody, I have a folder with many files: Files with 8 columns: X 123 A B C D E F And files with 7 columns: X1234 A B C D E F I am trying to find a way to extract the 5th column when the files have eight columns, or the 4th column when the files have... (3 Replies)
Discussion started by: Tzole
3 Replies

9. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies

10. Shell Programming and Scripting

sed or awk to remove specific column to one range

I need to remove specific column to one range source file 3 1 000123456 2 2 000123569 3 3 000123564 12 000123156 15 000125648 128 000125648 Output required 3 000123456 2 000123569 3 000123564 12 000123156 15 000125648 128 000125648 (6 Replies)
Discussion started by: ranjancom2000
6 Replies
hp-makeuri(1)							   User Manuals 						     hp-makeuri(1)

NAME
hp-makeuri - Device URI Creation Utility DESCRIPTION
Creates device URIs for local and network connected printers for use with CUPS. SYNOPSIS
hp-makeuri [OPTIONS] [SERIAL NO.|USB ID|IP|DEVNODE] SERIAL NO.|USB ID|IP|DEVNODE USB IDs (usb only): "xxx:yyy" where xxx is the USB bus ID and yyy is the USB device ID. The ':' and all leading zeroes must be present. (Use the 'lsusb' command to obtain this information. See Note 1.) IPs (network only): IPv4 address "a.b.c.d" or "hostname" DEVNODE (parallel only): "/dev/parportX", X=0,1,2,... SERIAL NO. (usb and parallel only): "serial no." OPTIONS
To specify the port on a multi-port JetDirect: -p<port> or --port=<port> (Valid values are 1*, 2, and 3. *default) Show the CUPS URI only (quiet mode): -c or --cups Show the SANE URI only (quiet mode): -s or --sane Show the HP Fax URI only (quiet mode): -f or --fax Set the logging level: -l<level> or --logging=<level> <level>: none, info*, error, warn, debug (*default) Run in debug mode: -g (same as option: -ldebug) This help information: -h or --help EXAMPLES
USB: $ hp-makeuri 001:002 Network: $ hp-makeuri 66.35.250.209 Parallel: $ hp-makeuri /dev/parport0 USB or parallel (using serial number): $ hp-makeuri US123456789 NOTES
1. Example using 'lsusb' to obtain USB bus ID and USB device ID (example only, the values you obtain will differ) : $ lsusb Bus 003 Device 011: ID 03f0:c202 Hewlett-Packard $ hp-makeuri 003:011 (Note: You may have to run 'lsusb' from /sbin or another location. Use '$ locate lsusb' to determine this.) SEE ALSO
hp-setup AUTHOR
HPLIP (Hewlett-Packard Linux Imaging and Printing) is an HP developed solution for printing, scanning, and faxing with HP inkjet and laser based printers in Linux. REPORTING BUGS
The HPLIP Launchpad.net site https://launchpad.net/hplip is available to get help, report bugs, make suggestions, discuss the HPLIP project or otherwise contact the HPLIP Team. COPYRIGHT
Copyright (c) 2001-14 Hewlett-Packard Development Company, L.P. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to distribute it under certain conditions. See COPYING file for more details. Linux 5.0 hp-makeuri(1)
All times are GMT -4. The time now is 03:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy