Search Results

Search: Posts Made By: binlib
7,136
Posted By binlib
single quote the &&.
single quote the &&.
3,121
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'
10,689
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...
850
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' '...
10,689
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
4,231
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})))%
1,609
Posted By binlib
grep . *.phe.ps |sed 's/\.phe\.ps:/ /'
grep . *.phe.ps |sed 's/\.phe\.ps:/ /'
14,473
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,689
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...
1,265
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...
3,556
Posted By binlib
$value=(split(/:/,$req_user_info))[3];
$value=(split(/:/,$req_user_info))[3];
20,862
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,135
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.
1,349
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...
17,048
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)
}'
3,251
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.
7,544
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,...
4,848
Posted By binlib
You can add: grep -q 'U:\\FOLDER' "$f" ||...
You can add:
grep -q 'U:\\FOLDER' "$f" || continue;before sed.
15,511
Posted By binlib
MY_STRING_VAR="QWERTU\ QWERTU\ QWERTU\ ...
MY_STRING_VAR="QWERTU\
QWERTU\
QWERTU\
QWERTU"
1,016
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.
1,436
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...
9,985
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,603
Posted By binlib
date +%b%-d
date +%b%-d
8,378
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>...
17,485
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...
Showing results 1 to 25 of 75

 

Featured Tech Videos

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