Search Results

Search: Posts Made By: tukuyomi
6,702
Posted By tukuyomi
With GNU date, you can do something like this, in...
With GNU date, you can do something like this, in sh or bash:
#!/bin/sh

# Past date in seconds since Epoch
past=$(date +%s --date "12/02/2013 11:21")

# Now in seconds since Epoch
now=$(date...
1,648
Posted By tukuyomi
Nothing fancy in the below script, just an...
Nothing fancy in the below script, just an all-in-one task:
awk '{$10=$7;$7=$8=$9="na"}
$10~/aa1/{$7="aa1"}
$10~/ab2/{$8="ab2"}
$10~/ac3/{$9="ac3"}
1' input_file > output_file
1,458
Posted By tukuyomi
Try this one instead : awk -F, '{A[$1 FS $2] =...
Try this one instead :
awk -F, '{A[$1 FS $2] = A[$1 FS $2] ? A[$1 FS $2] FS $NF : $N} END {for ( k in A ) print A[k]}' output/* > output-4.csv
1,554
Posted By tukuyomi
Try also this awk code as well :awk...
Try also this awk code as well :awk 'NR==FNR{A[++i,1]=$1;A[i,2]=$2;A[i,3]=$3;next}
{j=0;while(j++<i)if(($2==A[j,1])&&($3>=A[j,2])&&($3<=A[j,3]))print}
' filterfile datafile
1,554
Posted By tukuyomi
Edit - Nevermind, don't pay attention to this...
Edit - Nevermind, don't pay attention to this stupid question.


Is it acceptable to use a range file like this?
2,125
Posted By tukuyomi
Actually, Scrutinizer's reply is way more simple...
Actually, Scrutinizer's reply is way more simple to use :)
if ! $SERVICE status > /dev/null 2>&1uses exit status as well; in this case if $SERVICE status did not (!) exit with status 0; then rest of...
6,159
Posted By tukuyomi
Thanks Corona688 for your input ! Here is...
Thanks Corona688 for your input !
Here is another solution using AWK:
~/unix.com$ awk '{gsub("\r","");print > "file"$NF".txt"}' RAW
6,159
Posted By tukuyomi
awk '{print > "file"$NF".txt"}'...
awk '{print > "file"$NF".txt"}' RAW
6,159
Posted By tukuyomi
awk '{print > $3".txt"}' EDIT.txt awk...
awk '{print > $3".txt"}' EDIT.txt

awk '{print > $NF".txt"}' RAW
1,515
Posted By tukuyomi
Actual Debian Testing (Jessie) also uses gawk...
Actual Debian Testing (Jessie) also uses gawk after a "standard system" install.
You still get mawk if you choose to not install the "Standard system" at Tasksel install step.
9,781
Posted By tukuyomi
Here is a solution using awk:~/unix.com$ awk...
Here is a solution using awk:~/unix.com$ awk 'int(100*rand())%5<1' file
5 and 1 are the parameters you want to modify here : 1/5 = 20% in this example

To be more specific in your...
6,211
Posted By tukuyomi
\r is added by your text editor (Windows text...
\r is added by your text editor (Windows text editor?) at the end of each line (carriage return (http://en.wikipedia.org/wiki/Carriage_return#Typewriters))
You have to configure it to NOT write \r...
3,160
Posted By tukuyomi
Try this then (could not test my previous code...
Try this then (could not test my previous code 'cause I was on my smartphone)awk '!($0~x)' x="$3" file
2,867
Posted By tukuyomi
Try this ~/unix.com$ awk -F\| 'gsub(/...
Try this
~/unix.com$ awk -F\| 'gsub(/ /,"|")&&$4=$4?$4:"NULL"{print $1,$4}' f
The above script is overcomplicated, use Corona688's or in2nix4life's suggestion instead :p
2,867
Posted By tukuyomi
From your sample code, it's impossible to find...
From your sample code, it's impossible to find CDR3 on second and fourth line (ID 1 & 3). Is there any [tab] and [spaces] mixed?
13,235
Posted By tukuyomi
It's not sed but you can try this: ~/unix.com$...
It's not sed but you can try this:
~/unix.com$ awk '!A[$0]++' file
2,077
Posted By tukuyomi
One way : ~/unix.com$ awk...
One way :
~/unix.com$ awk 'NR==FNR{A[$1]++;next}A[$1]==2' file.txt file.txt
2,163
Posted By tukuyomi
Which shell are you using? In sh, dash,...
Which shell are you using?

In sh, dash, should run on bash as well:
#!/bin/sh

if [ ! "$1" ]; then
TEXT="Data_0"
else
TEXT="$1"
fi

if [ ! "$2" ]; then
Lines=45
else
Lines=$2
fi
1,648
Posted By tukuyomi
A bit straightforward, but it should do the...
A bit straightforward, but it should do the trick, at least on the sample you provided:
~/unix.com$ awk -F'=' '/NAME/{n=$2}/TARGET/{t=$2}/STATE/{s=$2}{if(s&&t&&(s!=t)){s="";t="";print n}}' file...
16,811
Posted By tukuyomi
#!/bin/bash sum=0 for i in $@; do...
#!/bin/bash
sum=0
for i in $@; do sum=$((sum+i)); done
echo $sum
exit 0~/unix.com$ bash script 4 5 6 7
22
See man bash (https://www.unix.com/man-page/All/1/bash/) for more infos
12,495
Posted By tukuyomi
Another way:~/unix.com$...
Another way:~/unix.com$ d='/root/logs/testing/today/'; echo ${d%/*/}
/root/logs/testing
886
Posted By tukuyomi
Here is a start (it's #!/bin/sh, but it should...
Here is a start (it's #!/bin/sh, but it should run with bash too):#!/bin/sh

FS='|'
file=; while [ "$file" != 'done' ]; do
[ "$file" ] && files="$files$file$FS"
read -p 'What is the name of...
16,509
Posted By tukuyomi
~/unix.com$ awk -v var='( |^)a:2( |$)'...
~/unix.com$ awk -v var='( |^)a:2( |$)' '$0~var{getline x;getline;print x RS $0}' file
a
b
~/unix.com$ grep -A2 '\( \|^\)a:2\( \|$\)' file
b:2 a:2
a
b
8,325
Posted By tukuyomi
~/unix.com$ grep -Ff f2 f1 The...
~/unix.com$ grep -Ff f2 f1
The reverse:~/unix.com$ grep -vFf f2 f1
In awk, based on Corona688's solution:
~/unix.com$ awk 'NR==FNR{A[$1]=1;next}A[$2]' f2 f1
The reverse:~/unix.com$ awk...
1,928
Posted By tukuyomi
Here is it, but i'm still not sure about output...
Here is it, but i'm still not sure about output file (my awk script below cat file2 to output (print>>"output")
the notmatched file contains the unmatched strings from file1
~/unix.com$ awk...
Showing results 1 to 25 of 75

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