Search Results

Search: Posts Made By: ks_reddy
3,101
Posted By RudiC
If running a script from a file like you did, you...
If running a script from a file like you did, you can't have the awk ' (opening) and final ' (closing) construct in the file. Try without.
1,385
Posted By Yoda
awk '!/ABC/{c=0}/ABC/{$0=$0"_"++c}1'...
awk '!/ABC/{c=0}/ABC/{$0=$0"_"++c}1' file
1,357
Posted By Aia
perl -nle 'm{((\d+/){2}\d+)} and $d=$1 or print...
perl -nle 'm{((\d+/){2}\d+)} and $d=$1 or print "$d,$_"' ks_reddy.csv
03/25/2016,A,B,C
03/25/2016,D,E,F
03/26/2016,1,2,3
03/26/2016,4,5,6
03/27/2016,6,4,3
03/27/2016,4,5,6
1,357
Posted By RudiC
Can be done in EXCEL pretty simple and fast....
Can be done in EXCEL pretty simple and fast. However, try awk '/^date/ {T = $2; next} {print T, $0}' OFS="," file1
03/25/2016,A,B,C
03/25/2016,D,E,F
03/26/2016,1,2,3
03/26/2016,4,5,6...
4,035
Posted By rdrtx1
try also: awk -F, 'NR==FNR {if ($2 !~ /./)...
try also:
awk -F, 'NR==FNR {if ($2 !~ /./) a[$1]=1; next;} ! a[$1] ' inputfile.csv inputfile.csv > output.csv
2,278
Posted By RudiC
Or awk '{printf "%s %d\n", $0, p+=$1==0}' file ...
Or awk '{printf "%s %d\n", $0, p+=$1==0}' file
0 1
1 1
2 1
3 1
0 2
3 2
4 2
5 2
6 2
0 3
1 3
2 3
3 3
or even awk '{print $0, p+=$1==0}' file
2,278
Posted By Don Cragun
As I am sure you already know, sed doesn't do...
As I am sure you already know, sed doesn't do arithmetic...
Try:
awk '
$1 == 0{ pat++ }
{ printf("%s %d\n", $0, pat) }
' data
If you want to try this on a Solaris/SunOS system, change awk to...
1,768
Posted By Don Cragun
With a million lines of input (assuming adjacent...
With a million lines of input (assuming adjacent timestamps represent monotonically increasing times [even though only minutes and seconds are given] and assuming that there is at least one entry...
1,768
Posted By pamu
$ awk -F ":" 'FNR==1{ti=$1*60+$2} {s=0} ...
$ awk -F ":" 'FNR==1{ti=$1*60+$2}
{s=0}
$1=="00"{s=3600;}
{print ($1*60+s+$2-ti)}' file

0
0.2
0.5
0.7
1
1.2
1.5
1,768
Posted By jim mcnamara
awk -F ':' 'FNR==1 {minutes=$1; old=$1; sec=$2;...
awk -F ':' 'FNR==1 {minutes=$1; old=$1; sec=$2; start=(minutes*60) +sec}
{$old!=$1} {minutes++; old=$1}
{print (minutes*60 + $2) - start } ' infile

Start with...
60,074
Posted By RudiC
Try sed '1 ! s/pattern/replacement/' file
Try sed '1 ! s/pattern/replacement/' file
60,074
Posted By MadeInGermany
sed '1d; s/PATTERN/REPLACEMENT/' filename
sed '1d; s/PATTERN/REPLACEMENT/' filename
60,074
Posted By Yoda
sed '2,$s/PATTERN1/PATTERN2/' filename awk...
sed '2,$s/PATTERN1/PATTERN2/' filename
awk 'NR==1{print}NR>1{sub(/PATTERN1/,"PATTERN2");print}' filename
2,376
Posted By Scrutinizer
Ow, yes.. I took it the . lines were meant to...
Ow, yes.. I took it the . lines were meant to represent the missing intermediate values...
2,376
Posted By radoulov
You'll need a small extra-tweak to leave the...
You'll need a small extra-tweak to leave the dot-lines (.) unchanged:

awk 'NR>1&&!/^\./{if($1<p)c++; p=$1; $0=sprintf( "%c", 65+c) $0}1' infile
2,828
Posted By Don Cragun
If you save the following in a file named...
If you save the following in a file named dropheaders and make it executable, have a file named input that contains the data, and a file named exclude that contains the list of headers to skip:...
2,940
Posted By pamu
you can avoid temp files but not temp file. you...
you can avoid temp files but not temp file.
you have to use atleast one temp file.

try

awk -F, '$1==A{$2+=1}1' OFS="," file > temp
mv temp file
2,940
Posted By Chubler_XL
Try: awk -F, '$2%2{$2++}1' OFS=, infile >...
Try:

awk -F, '$2%2{$2++}1' OFS=, infile > outfile
20,074
Posted By msabhi
awk -F,...
awk -F, 'NR==1{for(i=1;i<=NF;i++){if($i=="StepNo")x=i;}} NR>1{if($x=="1")print;}' input_file
Showing results 1 to 19 of 19

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