Search Results

Search: Posts Made By: scottaazz
6,656
Posted By scottaazz
A method to filter any number of items (and...
A method to filter any number of items (and non-consecutive) using awk:

put the following in a file called myawk.awk (or whatever)

BEGIN {
FS = " : ";
Skip["Record Number"] = 1;
...
1,316
Posted By scottaazz
Here is one that is not dependent on the middle...
Here is one that is not dependent on the middle column being limited from "A-C" (script can handle any items in the second column)

put this into a file called myawk.awk
NR == FNR{ c[$2]=1; next...
1,767
Posted By scottaazz
or | sed 's/.*\-\(.*\)\.\{3,\}$/\1/'
or

| sed 's/.*\-\(.*\)\.\{3,\}$/\1/'
2,853
Posted By scottaazz
Remove the "<>" around the file names dd...
Remove the "<>" around the file names

dd if=File1.dat of=File1Final.dat cbs=95 conv=unblock
1,055
Posted By scottaazz
Awk has an exponent function awk '{ for...
Awk has an exponent function

awk '{ for (i=1; i<=NF; i++) $i^=2; print }'
1,353
Posted By scottaazz
If the field "uniquenumber" is clustered together...
If the field "uniquenumber" is clustered together along with the "version" in order (as shown in your example), you can use:

awk -F_ '{ if ( ($1 != u) && (v > 1) ) { print l } u=$1; v=$2; l=$0 }'...
2,212
Posted By scottaazz
close to ogama's solution but you could have used...
close to ogama's solution but you could have used the field separator option of awk as follows:

awk -F'[: ]' '{ t[$1]+=$3 } END { for (i in t) print i, t[i] }' yourfile
1,521
Posted By scottaazz
All in awk: awk '{ $1 = $1 ".txt" ;if...
All in awk:

awk '{ $1 = $1 ".txt" ;if (a[$1]) { a[$1] = a[$1] "\n"; }; a[$1] = a[$1] "Fi Na=" $2 " no=" $3;} END { for (i in a) { print "Hello\nprl\n" a[i] "\nbye\nq" > i } }' A.txt
2,124
Posted By scottaazz
Just in case your next question is going to be...
Just in case your next question is going to be how to get the file name or other info. Perl has a good way of parsing (that is independent of operating systems):

perl -ane 'BEGIN { use...
29,725
Posted By scottaazz
the unix command "head" is made for that type of...
the unix command "head" is made for that type of operation. Use the following operation.

to remove the last two line of a file use:

head -n-2 yourfile
1,130
Posted By scottaazz
rdrtx1 is correct. Accessing your script...
rdrtx1 is correct.

Accessing your script from a web browser is similar to trying to run it as a different user. Chances are the userid of the web server does not have read/write access to...
3,102
Posted By scottaazz
Or you can use the paste command directly (each...
Or you can use the paste command directly (each dash represents a column). You can use the -d option of paste to set the delimiter (default is tab)


cat yourfile | paste - - -


if yourfile...
6,680
Posted By scottaazz
The issue is that you are attempting to read the...
The issue is that you are attempting to read the same file as you are writing. You can go ahead and use the code you wrote but instead of writing to the same file, write to a temporary file and then...
2,571
Posted By scottaazz
One more: paste partfile dbfile | awk...
One more:

paste partfile dbfile | awk '{print $1,$2,$4}'
18,279
Posted By scottaazz
The issue you are seeing could also be related to...
The issue you are seeing could also be related to the disk that you are using be setup using "automount" instead of in /etc/fstab.

Take a look at the file "/etc/autofs.conf" (general location to...
2,294
Posted By scottaazz
Another one: ls *.data | sed...
Another one:

ls *.data | sed 'p;s/\(.*\)_\([0-9]*\)\(\..*$\)/\2_\1\3/' | xargs -n2 mv
2,586
Posted By scottaazz
Or diff file1 file2 | awk '$1=="<" {print...
Or

diff file1 file2 | awk '$1=="<" {print $2}'
2,639
Posted By scottaazz
take a look at the getline man page. ...
take a look at the getline man page.


BEGIN {OFS = ",";}
{
nLine1 = split($0, Line1, ",");
getline;
$1 = Line1[1]; $3 = Line1[3];
for (i=4;i<=nLine1;i++) $i =...
12,688
Posted By scottaazz
You were close in your piece of code... use...
You were close in your piece of code...

use
awk '$1 ~ "\\."' file
3,716
Posted By scottaazz
Jim is correct (cool way of performing the task)...
Jim is correct (cool way of performing the task) but you need to switch the comparison operator in the if statement

awk 'FILENAME=="ID.txt" {arr[$0]++}
FILENAME=="source.txt" { for(i in arr) {if...
2,685
Posted By scottaazz
You could use something like the following: ...
You could use something like the following:

awk -F':' '{ idx=$1":"$2":"$3":"; rec[idx]=rec[idx]","$4 } END {for (var in rec) print var substr(rec[var],2) }' YOURGIDFILE
1,903
Posted By scottaazz
You may want to write an awk script... put...
You may want to write an awk script...

put the following into a file "filter.awk"
{
if ($0 ~ /^-/) { dash++ } else { if (dash==1) {out[++outcnt] = sprintf("%s %s",$1, $2) } }
if...
2,003
Posted By scottaazz
Would awk work for you? awk '($0 ~ /DDD/ &&...
Would awk work for you?

awk '($0 ~ /DDD/ && NF==1) { print }' yourfile
1,872
Posted By scottaazz
awk '{ if ($14 ~ /-/) {gsub("-","",$14);...
awk '{ if ($14 ~ /-/) {gsub("-","",$14); gsub("$","-",$14) } print }' yourfile
2,728
Posted By scottaazz
It is not good programming practice to perform...
It is not good programming practice to perform the read/write the way you describe but the following will fix it (yes, you need both "close" statements)

BEGIN{FS=OFS="|"; myfile =...
Showing results 1 to 25 of 28

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