Search Results

Search: Posts Made By: tukuyomi
6,752
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,714
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,514
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,675
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,675
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,219
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,300
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,300
Posted By tukuyomi
awk '{print > "file"$NF".txt"}'...
awk '{print > "file"$NF".txt"}' RAW
6,300
Posted By tukuyomi
awk '{print > $3".txt"}' EDIT.txt awk...
awk '{print > $3".txt"}' EDIT.txt

awk '{print > $NF".txt"}' RAW
1,566
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.
6,236
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...
9,966
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...
3,167
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
13,309
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,979
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?
2,979
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,118
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,231
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,671
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,907
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,554
Posted By tukuyomi
Another way:~/unix.com$...
Another way:~/unix.com$ d='/root/logs/testing/today/'; echo ${d%/*/}
/root/logs/testing
894
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,554
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
1,974
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...
1,974
Posted By tukuyomi
as in abcd 123 198 xyz1 In other words, each...
as in abcd 123 198 xyz1
In other words, each columns are separated by ' '(space)?
$1 in my script means the first field, as in abcd 123 198 xyz1, because I set FS to :

If anything else, sorry I...
Showing results 1 to 25 of 75

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