## In a row, replace negative sign and find minimum value among four columns

In a row, replace negative sign and find minimum value among four columns
# 1
02-19-2013
In a row, replace negative sign and find minimum value among four columns

Hi Friends,

I have an input file like this

Now, my output file is

Remove negative signs from columns 4,5,6 and7 and then find the minimum value among these 4 columns for a row, and print the minimum value.

 jacobs.smith View Public Profile for jacobs.smith Find all posts by jacobs.smith
# 2
02-19-2013
Try:
This User Gave Thanks to bartus11 For This Post:
 bartus11 View Public Profile for bartus11 Find all posts by bartus11
# 3
02-19-2013
This User Gave Thanks to Jotne For This Post:
 Jotne View Public Profile for Jotne Find all posts by Jotne
# 4
02-19-2013
Always 7 fields? bash has trinary operator ?: No multiply or sqrt. Could nest the last three. "tr -d '-' |" would remove the negatives in the string space.
This User Gave Thanks to DGPickett For This Post:
 DGPickett View Public Profile for DGPickett Find all posts by DGPickett
# 5
02-19-2013
try also (based on bartus11 solution):
 rdrtx1 View Public Profile for rdrtx1 Find all posts by rdrtx1
# 6
02-20-2013
Shouldn't you start with 5, as 4 is neve less than 4?

0-\$i save a multiply.

(Easier to criticize that to create! Slowly learning awk by osmosis!)
 DGPickett View Public Profile for DGPickett Find all posts by DGPickett

## Sed/awk to find negative numbers and replace with 1?

Greetings. I have a three column file, and there are some numbers in the second column that are <1. However I need all numbers to be positive, thus need to replace all those numbers with just one. I feel like there must be a simple way to use awk to find these numbers and sed to replace but can't...

## How to find a minimum value of a row?

input 1 2 3 4 5 2 8 2 1 1 1 4 2 1 5 4 4 4 2 1 3 2 2 6 7 4 5 4 5 5 5 4 3 3 5 I woud like to print a min of each row such that my output would look like 1 1 1 2 3

## minimum and maximum from columns

Hi Friends, my input file is this way chr1 100 120 abc chr1 100 121 def chr1 100 122 ghi chr2 240 263 kil chr2 240 276 ghj chr2 255 290 hjh my output chr1 100 122 abc chr2 240 276 kil chr2 255 290 hjh Basically, I want to match on first and second column and then print the...

## Linux command to find and replace occurance of more than two equal sign with "==" from XML file.

Please help me, wasted hrs:wall:, to find this soulution:- I need a command that will work on file (xml) and replace multiple occurrence (more than 2 times) Examples 1. '===' 2. '====' 3. '=======' should be replaced by just '==' Note :- single character should be replaced. (=...

## Help to move leading negative sign to trailing position

Hi All, I am having a file which contains negative numbers, wht i am doing is re-formattting the file(moving few columns and add few hard codings between), while reformatting i would want the negative numbers to have the sign as trailing rather than leading. Existing -2400.00 34 0.00...

## Extract minimum values among 3 columns

Hi. I would like to ask for helps on extracting a minimum values among three columns using gawk in tab separator. input file: as1 10 20 30 as2 22 21 23 as3 300 391 567 as4 19 20 15 Output file: as1 10 as2 21 as3 300 as4 15 I am extremely appreciate your helps and comments....

## Select several minimum values from row (MySQL)

Hello there. I've got the query like that SELECT count(tour_id) AS cnt FROM orders JOIN tours ON orders.tour_id=tours.id GROUP BY tour_id The result Is cnt 1 4 2 1 1 Now i have to select all records with minimum values in field "cnt" MySQL function min() returns only one....

## Find and replace duplicate column values in a row

I have file which as 12 columns and values like this 1,2,3,4,5 a,b,c,d,e b,c,a,e,f a,b,e,a,h if you see the first column has duplicate values, I need to identify (print it to console) the duplicate value (which is 'a') and also remove duplicate values like below. I could be in two...

## Count minimum columns in file

Hi All, Consider the file with following lines: 1,2,3,4 1,2,3, 5,6,7,7,8,9 1 I need to get the count of minimum columns per line. i.e. in above case, it should come out to be 1 since the last line only has 1 column. I tried following code: minCount = 0 wordCountPerLine = 0...

## Finding Minimum value per Row range of data

Here is an example of a file I am working with: C 4704 CB 1318 ASP 115 BGRF 1 weak 0.0% 4.33 C 4720 OD 1322 ASP 115 BGRF 1 weak 0.0% 3.71 O 4723 OD 1322 ASP 115 BGRF 1 weak 0.0% 3.48 O 4723 CG 1321 ASP 115 BGRF 1 weak 0.0% 4.34...