Search Results

Search: Posts Made By: binlib
5,412
Posted By binlib
single quote the &&.
single quote the &&.
1,347
Posted By binlib
(GNU) sort on Linux has a -z option to sort NULL...
(GNU) sort on Linux has a -z option to sort NULL delimited, multi-line records:
sed 's/^2013/\x0&/' log-file |sort -z |tr -d '\0'
2,633
Posted By binlib
Nice solutions, although the perl solution can be...
Nice solutions, although the perl solution can be shortened:

perl -le'$_=shift;s/\b(.)/\u$1/g;print' 'are utilities ready for hurricane sandy'
or
perl -ple's/\b./\u$&/g' <<<'are utilities ready...
639
Posted By binlib
nl does have the ability to only number lines...
nl does have the ability to only number lines matching (basic) regex. But it still leaves extra spaces which may not be acceptable to you. Notice the alignment of the second and last line.
nl -s' '...
2,633
Posted By binlib
bash$ set -- are utilities ready for hurricane...
bash$ set -- are utilities ready for hurricane sandy
bash$ echo "${@^}"
Are Utilities Ready For Hurricane Sandy
1,295
Posted By binlib
grep . *.phe.ps |sed 's/\.phe\.ps:/ /'
grep . *.phe.ps |sed 's/\.phe\.ps:/ /'
3,311
Posted By binlib
If you just want a quick and dirty estimation: ...
If you just want a quick and dirty estimation:
d=$(diff <(echo "$1" |sed 's/./&\n/g') <(echo "$2" |sed 's/./&\n/g') |grep -c '^[<>]')
echo $((100-100*d/(${#1}+${#2})))%
11,389
Posted By binlib
This is how you assign value to variable in bash...
This is how you assign value to variable in bash and most other shells:
var=val
not
set var = val
1,203
Posted By binlib
I will assume you want to change the header but...
I will assume you want to change the header but keep the rest of the 30 million lines. Since the new header has the same length, the following will open file for both reading and writing:
sed -Ee...
890
Posted By binlib
The offset in TZ for GNU date (or libc?) seemed...
The offset in TZ for GNU date (or libc?) seemed can't be bigger than 24. You need to convert the day part into -d argument as you said. Either override your date command with a function:
function...
2,216
Posted By binlib
$value=(split(/:/,$req_user_info))[3];
$value=(split(/:/,$req_user_info))[3];
15,353
Posted By binlib
Actually you CAN cat gz files and the result is a...
Actually you CAN cat gz files and the result is a valid gzip file.
1,048
Posted By binlib
A small nitpick, there is a small difference in...
A small nitpick, there is a small difference in performance between
for ...;do cmd >> file;done
and
for ...;do cmd; done > file
The latter only opens the output file once.
With GNU sed, you can...
889
Posted By binlib
If you are loading into Oracle using sqlldr, you...
If you are loading into Oracle using sqlldr, you can specify what you want through a load control file without the need to change the input file. Other loading utilities may have similar capabilities.
12,780
Posted By binlib
gawk 'BEGIN { for (i = 1; i < 13; ++i) ...
gawk 'BEGIN {
for (i = 1; i < 13; ++i)
m[strftime("%b", mktime("2012 " i " 1 0 0 0"))] = i
FS = "[ :,]+"
}
/all:/ {
print mktime($8 " " m[$2] " " $3 " " $4 " " $5 " " $6)
}'
2,322
Posted By binlib
sftp -b - user@host <<< 'put file' You can omit...
sftp -b - user@host <<< 'put file'
You can omit the "-b -" part, but then sftp will always exit with 0 even if it fails.
5,438
Posted By binlib
awk ' BEGIN { n =...
awk '
BEGIN {
n = split("1-9,11-36,38-49,51-56", a, "[^0-9]") - 1
for (i = 1; i <= n; i += 2)
l[i] = a[i+1] - (p[i] = a[i]) + 1
}
{
for (i = 1; i <= n; i += 2) {
x = substr($0,...
3,509
Posted By binlib
You can add: grep -q 'U:\\FOLDER' "$f" ||...
You can add:
grep -q 'U:\\FOLDER' "$f" || continue;before sed.
12,997
Posted By binlib
MY_STRING_VAR="QWERTU\ QWERTU\ QWERTU\ ...
MY_STRING_VAR="QWERTU\
QWERTU\
QWERTU\
QWERTU"
827
Posted By binlib
If your file is of fixed length (meaning that...
If your file is of fixed length (meaning that each line has the same length), then you can seek to the position of the target line and read the desired number lines.
944
Posted By binlib
-v Cause hexdump to display all input data. ...
-v Cause hexdump to display all input data. Without the -v option,
any number of groups of output lines, which would be identical
to the immediately preceding group...
8,427
Posted By binlib
As pointed out from the beginning, you need a "/"...
As pointed out from the beginning, you need a "/" before the "exit;". You claimed that it didn't make a difference. But it definitely has to be there.
1,250
Posted By binlib
date +%b%-d
date +%b%-d
16,711
Posted By binlib
Options to join used here are: -t$'\t' use tab...
Options to join used here are:
-t$'\t' use tab as input and output field separator
-a1 -a2 include unmatched lines from the first and second file
-e- use a "-" for missing fields
-j1 use the...
5,820
Posted By binlib
So much interest in this topic, let's try another...
So much interest in this topic, let's try another way for performance since his file is huge. This will edit the file in place and should be blazing fast.

linux$ cat t.c
#include <stdlib.h>...
Showing results 1 to 25 of 75

 

Featured Tech Videos

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