Sponsored Content
Top Forums Shell Programming and Scripting Deleting consecutive equal values in a file Post 302925559 by RavinderSingh13 on Monday 17th of November 2014 11:47:52 PM
Old 11-18-2014
Hello Vamsikrishna928,

Following may help you in same.

Code:
awk -F"," '{for(i=1;i<=NF;i++){if($i == V){$i="\b"} if(i==NF){ORS="";print $i"\n"} else {print $i;V=$i}}}' ORS="," Input_file

Output will be as follows.
Code:
a,b,c,d,e,f,g

Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

My Values are Equal but They are Not

Does anybody understand why this is not being interpreted as true. Script: #!/bin/bash errored=`grep "errored" new_update_scripts.txt` echo $errored = "errored" if ; then echo true else echo false fi Output: $ UpdateScripts errored = errored false (7 Replies)
Discussion started by: scottwmackey
7 Replies

2. Shell Programming and Scripting

concatenate consecutive field values

Hi, I have a file like this A Bob A Sam A John B David C Paul C Sandra If the consecutive field values in column one is same, then concatenate the corresponding strings. So, I need an output like this, A Bob_Sam_John B David C Paul_Sandra I usually work with excel but... (3 Replies)
Discussion started by: polsum
3 Replies

3. Programming

FORTRAN: Getting Consecutive DIST Values

I have this code and I want to get the first two consecutive distances (obtained by calling GET_TH(IT, 'DIST', DIST) at index IT, the result stored in DIST) for which (ITFLG(IT) .NE. 1). L_FIRST get the first DIST for which ITFLG(IT) .NE. 1. Getting a bit confused on how to achieve this. ... (0 Replies)
Discussion started by: kristinu
0 Replies

4. Shell Programming and Scripting

compare columns for equal values and output a summary

Hi all I am trying to scan a file that has 3 columns: red blue 123351 red blue 848655 red blue 126354 red blue 023158 black white 654896 red blue 650884 I want an output that sums the rows that have matching columns 1 and 2 :wall: red blue has 5 entries black white has 1 entry ... (4 Replies)
Discussion started by: reno
4 Replies

5. Shell Programming and Scripting

AWK: combining consecutive values in a field

Hi, Here is my sample input X 2 AAA Y 3 BBB Y 2 CCC Z 4 DDD In field 1, if the value of one line is same as that of next line, I want to concatenate the corresponding value of the second line in the third field with the value of the third field of first line. And I dont need the third... (2 Replies)
Discussion started by: polsum
2 Replies

6. Shell Programming and Scripting

How to compare the values of a column in awk in a same file and consecutive lines..

I would like to compare the values of 2nd column of consecutive lines of same file in such a way so that if the difference between first value and second value is more than 100 it should print complete line else ignore line. Input File ========== PDB 2500 RTDB 123 RTDB-EAGLE 122 VSCCP 2565... (4 Replies)
Discussion started by: manuswami
4 Replies

7. UNIX for Dummies Questions & Answers

Replacing values in a column if they equal a certain value

Hi, I have a tab delimited text file where some lines have the string "NA" in the second column. For these lines, I want to replace NA with the value in the first column, the symbol underscore followed by the value in the fourth column. How do I go about doing that? Thanks! Input: 1 ... (3 Replies)
Discussion started by: evelibertine
3 Replies

8. Shell Programming and Scripting

Adding the corresponding values for every 5th consecutive numbers

Dear All, I have a file which is as follows: Input File: 231 100.1 233 99 235 200.9 238 80.1 239 90.2 240 77.0 243 99.5 245 16.20 246 13.55 247 11.8 249 13.7 250 99.6 (1 Reply)
Discussion started by: NamS
1 Replies

9. Shell Programming and Scripting

awk print values between consecutive lines

I have a file in below format: file01.txt TERM TERM TERM ABC 12315 68.53 12042013 165144 ABC 12315 62.12 12042013 165145 ABC 12315 122.36 12052013 165146 ABC 12315 582.18 12052013 165147 ABC 12316 2.36 12052013 165141 ABC 12316 ... (8 Replies)
Discussion started by: alex2005
8 Replies

10. Shell Programming and Scripting

Delete row if both percentage values are equal to zero

Hello, I have compiled a script but I have stucked at one point. Each line contains two pcs of % value and what I want to do is to delete any line if both % values are zero. data: expected output: ow3 should be deleted as both percentage value in related line are equal to zero. ... (2 Replies)
Discussion started by: baris35
2 Replies
cow-shell(1)							     cowdancer							      cow-shell(1)

NAME
cow-shell - Start a copy-on-write session and invoke a shell. SYNOPSIS
cow-shell [commandline] DESCRIPTION
cow-shell Executes specified command with cowdancer or a shell if no command-line option is given. Inside the cowdancer session, files under the current directory are protected in a way so that a write operation to an i-node which existed at the point of running cow-shell is not modified. Useful for managing hard-linked source-trees and scratch-filesystems. EXAMPLES
cp -al cowdancer/ cowdancer.new && cd cowdancer.new && cow-shell Create a hardlinked tree, and cd into the newly created tree. After invoking cow-shell inside that tree, a write operation against a file that is hardlinked with the original tree will be copied to a new file before write. cp -al cowdancer/ cowdancer.new && cd cowdancer.new && cow-shell debuild Tries to run dpkg-buildpackage on the new tree, to avoid damage to the original tree. Configure debuild to ignore .ilist files, through -i or -I option. FILES
.ilist Generated dynamically in the current directory. The file contains the list of i-node numbers that should be protected from write operation. /usr/lib/cowdancer/libcowdancer.so The shared library used internally that overrides some functions that potentially write to files. This library implements the COW feature and is preloaded with LD_PRELOAD. /bin/cp Used for copying. Requires GNU option -a to be functional. ENVIRONMENT
COWDANCER_ILISTFILE The path to the current .ilist file. COWDANCER_IGNORE Used internally to work around infinite loops. It will be unset. LD_PRELOAD Utilized to preload libcowdancer.so COWDANCER_DEBUG Debugging option. Enables debug messages. cowdancer will give verbose debug messages in standard error output. COWDANCER_SO Debugging option. Specifies a different path for libcowdancer.so. COWDANCER_REUSE=yes Enables reuse of cowdancer .ilist file found for consecutive runs of cow-shell. RETURN VALUE
The functions that are overridden with cowdancer will give an errno value of ENOMEM when there is a problem. System isn't really out of memory, but this error code is chosen because this error is usually handled gracefully by applications. RESTRICTIONS
Can only support directories that are scanned by cow-shell command. The operation is not semantically correct when files are originally hardlinked, hardlinks are always broken. Does not support anything when LD_PRELOAD trick does not work. Does not work unless hardlinks are supported on the filesystem. Not very user-friendly. Leaves .ilist file around. AUTHOR
Junichi Uekawa (dancer@debian.org) Upstream page is available at http://www.netfort.gr.jp/~dancer/software/cowdancer.html SEE ALSO
cowdancer-ilistcreate (1) cowdancer 2006 Jan 25 cow-shell(1)
All times are GMT -4. The time now is 10:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy