Sponsored Content
Top Forums Shell Programming and Scripting Change text at a variable position Post 302732761 by RudiC on Monday 19th of November 2012 06:02:41 AM
Old 11-19-2012
Your request is a bit difficult to interpret. If you want field $3 to be considered in ALL lines, remove the NR<=2 condition. Try this:
Code:
$ awk -F: -vsea=2000 -vrep=5000 'NR<=2 && $3==sea {$3=rep} 1' OFS=":" file
test1:zz:5000:2000:zzz
te:a:5000:3333:bbb
testabs:x:2004:3000:cccc

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Change Position of word character

Hi, I have following format in file aaa with content below, and would like to seek help from forumer about how to change and swap the position on 2nd field. 5874957|901125| 95874960|650614| 95874966|870308| 901125 to be changed as 25-11-1990 for eg Can someone help please ?? :) ... (6 Replies)
Discussion started by: cedrichiu
6 Replies

2. Shell Programming and Scripting

Cut position as a variable

Hi All, I wish to cut an input by using the below command but i would want to have the cut position as a variable. For eg, the position number is 11 now and i wish that this number is being assigned to a variable before putting into the cut function. Can this be done ? Can any expert help?... (1 Reply)
Discussion started by: Raynon
1 Replies

3. Shell Programming and Scripting

How to change a segment in a particular position

I need help in removing a leading zero in a particular position. For eg.: XYZ*04567472*0099*020091231*0123*0.12 In the above line, I want to replace "*0123" with "123" and "0.12" with ".12". I want to remove the leading zero only in position number 4 and 5 (the bolded segments) I was able... (10 Replies)
Discussion started by: ananthmm
10 Replies

4. Shell Programming and Scripting

Change many columns position/order

Hi everyone, Please some help over here. (I´m using cygwing) I have files with 40 columns and 2000 lines in average. I´m trying to change the order position as follow. Original columns position:... (3 Replies)
Discussion started by: cgkmal
3 Replies

5. Shell Programming and Scripting

Remove text from n position to n position sed/awk

I want to remove text from nth position to nth position couple of times in same line my line is "hello is there anyone can help me with this question" I need like this ello is there anyone can help me with question 'h' is removed and 'this' removed from the line. I want to do this... (5 Replies)
Discussion started by: elamurugu
5 Replies

6. Shell Programming and Scripting

Get character position within variable

Hi all let's say i have a file named 1234_v2_abcd i need to find the position of the character located after _v, in above case this would be character number 2 the count of the characters before _v can change, but i always have a number after _v can anybody help :) (4 Replies)
Discussion started by: gigagigosu
4 Replies

7. Shell Programming and Scripting

position change

Hi All, input file: echo "a|b|c|d|test|123|same" | awk 'BEGIN {FS=OFS="|"} {print $1,$2,$7,$4,$5,$6}' Got Output : a|b|same|d|test|123 This is the sample input file with less fields. But my original file contains more field values. How to replace last value to 3rd postion value. Because... (8 Replies)
Discussion started by: Jairaj
8 Replies

8. UNIX for Dummies Questions & Answers

Change a character based on its position number

Hi I have a text file that I want to change some of the characters based on their position. My file contain multiple lines and characters should be counted continuously line by line. For example, I want to convert the 150th T to C. What can I do? Here is a portion of my file:... (10 Replies)
Discussion started by: a_bahreini
10 Replies

9. UNIX for Beginners Questions & Answers

Delete columns with a specific title XXX, where the position change in each file

Goodmorning, I know how to cut a string and a column, and how to find a word. I have a file with over 100 columns. All columns have a title in the first line. I have to delete all columns with the XXX title. I can't use cut -f because the position of XXX columns change in each file, and in... (14 Replies)
Discussion started by: echo manolis
14 Replies

10. Programming

Python variable at different position

I have a file which records banking transactions say like below. user1 has deposited 10,000$ in his account user2 has deposited 11,000$ in his account user1 has withdraw today 5000$ from his account. Lets say i read this file and convert each line as a list. username= word action=... (1 Reply)
Discussion started by: sahil_shine
1 Replies
cmx(8)							      System Manager's Manual							    cmx(8)

NAME
cmx - Generic communication exerciser SYNOPSIS
/usr/field/cmx [-b [minbaud]-[maxbaud]] [-h] [-ofile] [-tn] -l line-n... OPTIONS
Use this option to specify the minimum, maximum, or range of baud rates to test. Prints help messages about the cmx command. Test all the listed tty lines, where n equals the lines to test according to the special device file entries in the /dev directory, such as 00, 12, or 42-53 Saves output diagnostics in file. Specifies the run time in minutes (n). The default is to run until a [CTRL-C] or a kill -15 pid is sent to the process. DESCRIPTION
The cmx exerciser writes, reads, and validates random data and packet lengths on a specified communications line. The line being tested must have a loopback connector attached to the distribution panel, or the cable and the line must be disabled in the /etc/inittab file and a non-modem line; the CLOCAL option must be set to on. The exerciser runs until a [CTRL-C] or a kill -15 pid is sent to the process. A logfile for you to examine and then remove is created in the current working directory; errors can be listed in the logfile. You must specify the -l option followed by the lines to test. The line-n arguments identify the lines to be tested. A maximum of 32 lines can be tested at any one time. The line-n arguments are specified as names taken from the /dev directory without the letters "tty." For example, if the /dev directory lists tty03, the line-n argument is 03. The Devices section lists the devices that can be tested. RESTRICTIONS
If you want to run a system exerciser over an NFS link or on a diskless system, there are some restrictions. For exercisers such as fsx(8) that need to write into a file system, the target file system must be writable by root. Also, the directory from which an exerciser is exe- cuted must be writable by root because temporary files are written into the directory. These restrictions can be difficult to adhere to because NFS file systems are often mounted in a way that prevents root from writing into them. Some of the restrictions may be adhered to by copying the exerciser into another directory and then executing it. Pseudo devices (devices whose first character after tty is any alphabetic character, other than lowercase d) cannot be tested. Also lat devices with major #5 cannot be tested. DEVICES
Use the file command on /dev/tty* to find out which tty line corresponds to a device line number. EXAMPLES
The following example runs the cmx exerciser for 60 minutes on lines 00, 13, 22, and 32: % /usr/field/cmx -t60 -l 00 13 22 32 The following example runs the cmx exerciser on lines 11, 42, 45, and 76 in the background until interrupted by a [CTRL-C] or a kill -15 pid: % /usr/field/cmx -l 11 42 45 76 & The following example runs the cmx exerciser on line 11, specifying a range of baud rates to test. % /usr/field/cmx -b9600-38400 -l 11 SEE ALSO
Commands: diskx(8), fsx(8), memx(8), shmx(8), tapex(8) cmx(8)
All times are GMT -4. The time now is 09:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy