Search Results

Search: Posts Made By: Twinklefingers
16,871
Posted By alister
Variations of vgersh99's solution which don't...
Variations of vgersh99's solution which don't rebuild $0 when $2 is non-negative:

awk '$2>=0 || ($2=1)' OFS='\t' myFile

or

awk '$2<0 {$2=1} 1' OFS='\t' myFile

Regards,
Alister
16,871
Posted By vgersh99
awk '{$2=($2<0)?1:$2}1' OFS=='\t' myFile
awk '{$2=($2<0)?1:$2}1' OFS=='\t' myFile
16,871
Posted By Akshay Hegde
OFS variable you have to use like below awk...
OFS variable you have to use like below
awk '{$2=($2<0)?1:$2}1' OFS='\t' myfile
16,871
Posted By vgersh99
awk '{$2=($2<0)?1:$2}1' myFile OR sed...
awk '{$2=($2<0)?1:$2}1' myFile
OR
sed 's/-[0-9][0-9]*/1/' myFile
42,490
Posted By vgersh99
awk -v s=100 '{print $1-s, $2+s}' myFile
awk -v s=100 '{print $1-s, $2+s}' myFile
2,147
Posted By Don Cragun
As long as all of your input lines are in the...
As long as all of your input lines are in the same format and have data in the 3rd field in the same order, the easy way to do this is just to use tab, equal sign, and semicolon as field separators...
1,636
Posted By Peasant
See if this helps awk '...
See if this helps

awk ' {gsub("[^0-9]|Value4",",",$NF); split($NF,a,","); for (i in a) $NF=a[3]+a[4]+a[5]+a[6] }1 ' inputfile
4,403
Posted By Scrutinizer
Indeed there are GGG's, so the G's should shift...
Indeed there are GGG's, so the G's should shift per 1 therefore GG kan not be used a record separator. So then this should do, which should work with any awk:

awk 'p~/GG$/{print p} {$0=p $0;...
4,403
Posted By wisecracker
This has its flaws as you will see but it is a...
This has its flaws as you will see but it is a starter...

#!/bin/bash --posix
textfile=$(tr -d '\n' < ~/flatfile.dat)
echo ""
echo "$textfile"
echo ""
for n in $( seq 19 1 ${#textfile} )
do...
1,777
Posted By Scott
grep -B1 -f ...
grep -B1 -f ...
2,756
Posted By Yoda
Using grep command with -f and -v option: echo...
Using grep command with -f and -v option:
echo -e "deleted\n$( grep -f A.txt -v B.txt )"
echo -e "added\n$( grep -f B.txt -v A.txt )"
2,756
Posted By Corona688
The comm utility sounds like what you want, then....
The comm utility sounds like what you want, then. It outputs three columns -- lines only found in file 1, lines only found in file 2, and lines found in both. It needs sorted (or at least...
10,823
Posted By complex.invoke
awk...
awk '{printf("%d:",NR);len=0;for(i=1;i!=NF;++i){len+=length($i)+1;printf("%d ",len)}printf("\n")}' FS="?" infile

or

awk '{printf("%d:",NR)}{for(i=1;i<=NF;++i)if($i == "?")printf("%d...
4,804
Posted By Scrutinizer
See if this works: awk 'NR>1{p=$0;sub($1...
See if this works:
awk 'NR>1{p=$0;sub($1 ORS,x,p);sub(ORS,x,p); print RS $1 ORS substr(p, 4921,6534-4921+1)}' RS=\> OFS= infile
37,385
Posted By sramirez
[Solved] sort on multiple columns
Howdy!

Need to sort a large .txt file containing the following, using sort. First based on the 1st column, and then on the 2nd column:

Group01.01 1000500 31 0.913 -1.522974494...
Showing results 1 to 15 of 15

 
All times are GMT -4. The time now is 11:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy