Sponsored Content
Top Forums Shell Programming and Scripting How to change a number on a specific lines in a file with shell? Post 302606006 by miriammiriam on Friday 9th of March 2012 10:27:51 AM
Old 03-09-2012
Hello birei,

Thank you for your quick kindly answer, but here is another problem:

when I type the command you gave:

Code:
$ awk '$10 == "FRO" { $11 += 1.3 } { print }' infile

I got the lines shifted.

Code:
 2009 10 1 2048 30.3 L   40.378   28.578   6.7   FRO  12 0.6 1.3LFRO 2.2CFRO   
 2009 10 1 2048 30.3 L 40.378 28.578 6.7 FRO 13.3 0.6 1.3LFRO 2.2CFRO

It could not be displayed here but the spaces which are two, decrease to one space.

So, my file does not work since the format is changed Smilie Do have any idea why this happens?

Thank you very much!!!!!

Best..

Last edited by Corona688; 03-09-2012 at 11:35 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script to read specific lines in a file

I have a file with contents as follows Record 1: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 5: Rejected - Error on table "DWO"."P2G_CUST_EVENTS". ORA-00001: unique constraint (DWO.CUST_EVENTS_PK) violated Record 6:... (5 Replies)
Discussion started by: varshanswamy
5 Replies

2. Shell Programming and Scripting

extract the lines between specific line number from a text file

Hi I want to extract certain text between two line numbers like 23234234324 and 54446655567567 How do I do this with a simple sed or awk command? Thank you. ---------- Post updated at 06:16 PM ---------- Previous update was at 05:55 PM ---------- found it: sed -n '#1,#2p'... (1 Reply)
Discussion started by: return_user
1 Replies

3. SCO

Why? I can not change the number of lines to print

hi My problem now is that if shipping options as -o length = 88 it says the following: # lp -o length=88 -dhp4015 /etc/hosts UX:lp: ERROR: The following options can't be handled: -o length= TO FIX: The printer(s) that otherwise qualify for printing your request can't handle one or more of... (2 Replies)
Discussion started by: Edgar Guevara
2 Replies

4. Shell Programming and Scripting

Delete all lines that start with a bigger number of a specific one.

E.g. the file is like this: I want to delete all lines that begin with a number larger than 2, ignoring the lines that doesn't begin with a number! PS:'2' is actually a variable that can have a lot of values:b:i bet you got it (10 Replies)
Discussion started by: hakermania
10 Replies

5. Shell Programming and Scripting

KSH SHELL: problem calculation number of lines inside compressed file

Hi Gurus, I am working with a korn shell script to simplify some operations of calculation number of lines inside compressed file. The called function (inside a cycle) is the following: ######################################### # F.ne: CheckCount #########################################... (3 Replies)
Discussion started by: GERMANICO
3 Replies

6. UNIX for Dummies Questions & Answers

How to use sed to copy specific lines from a file using shell variables?

hello! I am trying to use sed to copy specific set of lines from a file for which the starting and ending line numbers of the lines to be copied are stored in shell variables. How can i copy those lines? if the input_file is something like this and if the following is the script a=2 b=4... (4 Replies)
Discussion started by: a_ba
4 Replies

7. Shell Programming and Scripting

Change default shell of a specific user with awk

I would like to replicate the functionality of chsh (or passwd -e) by awk. This is what I got so far, but I think there should be an easier way to search and replace field $7 only for lines beginning with user_name: awk -v user_name="$user_name" -v new_shell="$new_shell" -F: '$1 == user_name {... (2 Replies)
Discussion started by: nomad84
2 Replies

8. Shell Programming and Scripting

How to change a number on a specific line with cshell or shell?

Hello all, I need to change a number in a file by adding some residuals respectively To make it clear, I need to add 0.11 to the number between 24-28 (which is below the SECON) for all the lines starting with FRR1 or I need to add 0.13 to the number between 24-28 (which is below the... (9 Replies)
Discussion started by: miriammiriam
9 Replies

9. Shell Programming and Scripting

To change Specific Lines in An XML file

hi Guys, this is my requirement, there is a huge xml file of this i have to change 3 lines with out opening the file /users/oracle > cat lnxdb-pts-454.xml|egrep "s_virtual|s_cluster|s_dlsnstatus" <cluster_port oa_var="s_clusterServicePort">9998</cluster_port> <host... (2 Replies)
Discussion started by: smarlaku
2 Replies

10. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies
funcolumnactivate(3)						SAORD Documentation					      funcolumnactivate(3)

NAME
FunColumnActivate - activate Funtools columns SYNOPSIS
#include <funtools.h> void FunColumnActivate(Fun fun, char *s, char *plist) DESCRIPTION
The FunColumnActivate() routine determines which columns (set up by FunColumnSelect()) ultimately will be read and/or written. By default, all columns that are selected using FunColumnSelect() are activated. The FunColumnActivate() routine can be used to turn off/off activa- tion of specific columns. The first argument is the Fun handle associated with this set of columns. The second argument is a space-delimited list of columns to activate or de-activate. Columns preceded by "+" are activated and columns preceded by a "-" are de-activated. If a column is named with- out "+" or "-", it is activated. The reserved strings "$region" and '$n' are used to activate a special columns containing the filter region value and row value, respectively, associated with this row. For example, if a filter containing two circular regions is specified as part of the Funtools file name, this column will contain a value of 1 or 2, depending on which region that row was in. The reserved strings "$x" and "$y" are used to activate the current binning columns. Thus, if the columns DX and DY are specified as binning columns: [sh $] fundisp foo.fits[bincols=(DX,DY)] then "$x" and "$y" will refer to these columns in a call to FunColumnActivate(). In addition, if the activation string contains only columns to be activated, then the routine will de-activate all other columns. Simi- larly, if the activation string contains only columns to de-activate, then the routine will activate all other columns before activating the list. This makes it simple to change the activation state of all columns without having to know all of the column names. For example: o "pi pha time" # only these three columns will be active o "-pi -pha -time" # all but these columns will be active o "pi -pha" # only pi is active, pha is not, others are not o "+pi -pha" # same as above o "pi -pha -time" # only pi is active, all others are not o "pi pha" # pha and pi are active, all others are not o "pi pha -x -y" # pha and pi are active, all others are not You can use the column activation list to reorder columns, since columns are output in the order specified. For example: # default output order fundisp snr.ev'[cir 512 512 .1]' X Y PHA PI TIME DX DY -------- -------- -------- -------- --------------------- -------- -------- 512 512 6 7 79493997.45854475 578 574 512 512 8 9 79494575.58943175 579 573 512 512 5 6 79493631.03866175 578 575 512 512 5 5 79493290.86521725 578 575 512 512 8 9 79493432.00990875 579 573 # re-order the output by specifying explicit order fundisp snr.ev'[cir 512 512 .1]' "time x y dy dx pi pha" TIME X Y DY DX PI PHA --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 512 512 574 578 7 6 79494575.58943175 512 512 573 579 9 8 79493631.03866175 512 512 575 578 6 5 79493290.86521725 512 512 575 578 5 5 79493432.00990875 512 512 573 579 9 8 A "+" sign by itself means to activate all columns, so that you can reorder just a few columns without specifying all of them: # reorder 3 columns and then output the rest fundisp snr.ev'[cir 512 512 .1]' "time pi pha +" TIME PI PHA Y X DX DY --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 7 6 512 512 578 574 79494575.58943175 9 8 512 512 579 573 79493631.03866175 6 5 512 512 578 575 79493290.86521725 5 5 512 512 578 575 79493432.00990875 9 8 512 512 579 573 The column activation/deactivation is performed in the order of the specified column arguments. This means you can mix "+", "-" (which de- activates all columns) and specific column names to reorder and select columns in one command. For example, consider the following: # reorder and de-activate fundisp snr.ev'[cir 512 512 .1]' "time pi pha + -x -y" TIME PI PHA DX DY --------------------- -------- -------- -------- -------- 79493997.45854475 7 6 578 574 79494575.58943175 9 8 579 573 79493631.03866175 6 5 578 575 79493290.86521725 5 5 578 575 79493432.00990875 9 8 579 573 We first activate "time", "pi", and "pha" so that they are output first. We then activate all of the other columns, and then de-activate "x" and "y". Note that this is different from: # probably not what you want ... fundisp snr.ev'[cir 512 512 .1]' "time pi pha -x -y +" TIME PI PHA Y X DX DY --------------------- -------- -------- -------- -------- -------- -------- 79493997.45854475 7 6 512 512 578 574 79494575.58943175 9 8 512 512 579 573 79493631.03866175 6 5 512 512 578 575 79493290.86521725 5 5 512 512 578 575 79493432.00990875 9 8 512 512 579 573 Here, "x" and "y" are de-activated, but then all columns including "x" and "y" are again re-activated. Typically, FunColumnActivate() uses a list of columns that are passed into the program from the command line. For example, the code for funtable contains the following: char *cols=NULL; /* open the input FITS file */ if( !(fun = FunOpen(argv[1], "rc", NULL)) ) gerror(stderr, "could not FunOpen input file: %s ", argv[1]); /* set active flag for specified columns */ if( argc >= 4 ) cols = argv[3]; FunColumnActivate(fun, cols, NULL); The FunOpen() call sets the default columns to be all columns in the input file. The FunColumnActivate() call then allows the user to con- trol which columns ultimately will be activated (i.e., in this case, written to the new file). For example: funtable test.ev foo.ev "pi pha time" will process only the three columns mentioned, while: funtable test.ev foo.ev "-time" will process all columns except "time". If FunColumnActivate() is called with a null string, then the environment variable FUN_COLUMNS will be used to provide a global value, if present. This is the reason why we call the routine even if no columns are specified on the command line (see example above), instead of calling it this way: /* set active flag for specified columns */ if( argc >= 4 ){ FunColumnActivate(fun, argv[3], NULL); } SEE ALSO
See funtools(7) for a list of Funtools help pages version 1.4.2 January 2, 2008 funcolumnactivate(3)
All times are GMT -4. The time now is 10:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy