How can I match values in one file to ranges from another?
if the data file sizes are not huge, there is a simpler way $ join input1 input2 | awk ‘$5<$4 && $3<$5 {print $2, $5-$3+1}’ B100002 32 B100043 15 B123465 3
if the data file sizes are not huge, there is a simpler way $ join input1 input2 | awk ‘$5<$4 && $3<$5 {print $2, $5-$3+1}’ B100002 32 B100043 15 B123465 3
<(command) is a bashism called Process substitution You have to run your script with bash, eg do bash script.bash Or if you want to use sh, you could write the results to a file, like this : grep eth0 /proc/net/dev > file1 sleep 1 ; grep eth0 /proc/net/dev > file2 diff file1 file2
With GNU grep: grep ‘[[:alpha:]]’ file or GNU sed: sed ‘/[[:alpha:]]/!d’ file Output: 0hjjAby68xp H5e
Bash is not very performant doing loops. Since you tagged the question python, python should be ok? def data_mask(col_val): mod = len(col_val) + sum(map(ord, col_val)) % 10 result = “” for i, ch in enumerate(col_val, mod + 1): absnum = abs(ord(ch) – i) if ‘A’ <= ch <= ‘Z’: ch = chr(ord(‘A’) + absnum % … Read more
You can also consider using groupby If your data is already in this format: [ [‘CZ’, ’12/27/07 3:55 PM’, ‘1198788900’, ‘42345’, ‘42346’,], [‘CZ’, ’12/27/07 5:30 PM’, ‘1198794600’, ‘42346’, ‘42300’,], [‘CZ’, ’12/27/07 7:05 PM’,’1198800300′, ‘42300’, ‘42000’,], [‘JB’, ’12/27/07 7:05 PM’,’1198800300′, ‘13722’, ‘13500’,], [‘I’, ’12/27/07 7:05 PM’, ‘1198800300’, ‘4475’, ‘4572’] ] Then you can do this: #truncate … Read more
From what we can discern of this question, you’re attempting to create a programmatic rule to rename files ending in extensions stdout-captured, stderr-captured, and status-captured (assuming one typo) into files ending in extensions stdout-expected, stderr-expected, and status-expected, respectively. Obviously, if each of these definitions is inclusive of exactly one file, a rote mv may be … Read more
date -d’11/2/1998′ +%m%d%y 110298
If you can slurp whole input: perl -e’undef$/; $a=<>; print “$_\n” for $a=~m/(?:\b\S+\b\s+){5}your regexp(?:\s+\b\S+\b){5}/sg ‘ <input — 5 words of context.