Search Results

Search: Posts Made By: elixir_sinari
Forum: What is on Your Mind? 07-19-2016
1,438
Posted By elixir_sinari
When I started out on unix.com, I was awestruck...
When I started out on unix.com, I was awestruck by the ultra-compressed one-liners from the clever guys (Scrutinizer, you were my hero!!!). Over time, I learned from you guys and started doling out...
3,834
Posted By elixir_sinari
Have a look at the File::Find module. You could...
Have a look at the File::Find module.
You could store the arguments passed in a hash and then test the files/directories found.
Be a bit careful though...
Good luck.
885
Posted By elixir_sinari
Try this (with some assumptions): perl -pe...
Try this (with some assumptions):
perl -pe 'BEGIN{$/="ff45"}
$\ = (length >= 7 ? "\n" : "")' file
2,285
Posted By elixir_sinari
In the regex (pattern) part, not the replacement...
In the regex (pattern) part, not the replacement part. I think.
2,285
Posted By elixir_sinari
Do not leave people guessing. What error...
Do not leave people guessing.

What error message are you getting, if any, while trying your solution?
Or are you not getting the desired output?
What sed version are you using?
903
Posted By elixir_sinari
Try this (for starters) to get the "INSERT" DML...
Try this (for starters) to get the "INSERT" DML statements in one line:
perl -lne 'if ( $seq = (/^\s*INSERT/i .. /;\s*$/)) {
push @ddl, $_;
if ($seq =~ /E0$/) { print @ddl; @ddl = () }
}'...
1,284
Posted By elixir_sinari
You may try this: awk -F, 'FNR==NR{ if(NR>1)...
You may try this:
awk -F, 'FNR==NR{
if(NR>1) a[$1]=$0
next}
{if(FNR==1) next
$2 = ($2 in a ? a[$2] : "NOT FOUND") }
1' OFS=, file2.csv file1.csv
816
Posted By elixir_sinari
awk -F'\\^\\^' ... The value to the -F option...
awk -F'\\^\\^' ...
The value to the -F option is treated as a string with escape-sequence processing. So, an extra \ is needed so that escaped circumflexes (^) reach the regex engine.
759
Posted By elixir_sinari
If order of the output does not matter: perl...
If order of the output does not matter:
perl -lane '$max{$F[0]} = $F[1] unless exists $max{$F[0]}; $max{$F[0]} = $F[1] if $F[1] > $max{$F[0]};
END{ print "$_ $max{$_}" for keys %max}' file
6,663
Posted By elixir_sinari
Try: perl -lne 'push @w, /\bA(?:BC|DF)_\w+/g;...
Try:
perl -lne 'push @w, /\bA(?:BC|DF)_\w+/g; END{ print join ", ", @w if @w}' ABC.txt
934
Posted By elixir_sinari
It's better to set the input field separator to a...
It's better to set the input field separator to a tab character, to take care of the cases wherein the fields have spaces as part of data.
674
Posted By elixir_sinari
You should have read perlvar documentation (using...
You should have read perlvar documentation (using perldoc perlvar in most cases) before asking this question.

This is a special variable which controls the output buffering of the currently...
1,034
Posted By elixir_sinari
/\(.\)\1/!d : For all lines not matching the...
/\(.\)\1/!d :
For all lines not matching the pattern, delete the pattern space. The ! is for the pattern and not for the action d. This means that for all lines not having at least 1 consecutive...
1,616
Posted By elixir_sinari
A different type of Perl alternative (if you are...
A different type of Perl alternative (if you are interested):
perl -lpe '@a = split /(:)/, $_, -1; @a = map { ($_+1)%4 ? $a[$_] : "|" } 0..$#a if @a>3;
$_ = join("",@a)' file
This could be easily...
2,665
Posted By elixir_sinari
Or fuser.
Or fuser.
1,349
Posted By elixir_sinari
Could you show/post input sample/s? That will...
Could you show/post input sample/s? That will make things a lot better.
1,349
Posted By elixir_sinari
What do you mean by not working? Any errors? ...
What do you mean by not working? Any errors?

By the way, that command might not always do what you desire. It will print the last line of one file and the first line of the next file, if that...
915
Posted By elixir_sinari
And more. It also matches \n, \f and \r. And this...
And more. It also matches \n, \f and \r. And this is with ASCII. With some locales/Unicode, this shortcut may match many more characters.
2,646
Posted By elixir_sinari
Did you read my post carefully? I said tr -d '\0'...
Did you read my post carefully? I said tr -d '\0' < inputfile and not what you tried.

And, ^@ is the ASCII representation of the null character (in caret notation).
2,646
Posted By elixir_sinari
What do you actually mean by that? So, do you...
What do you actually mean by that?
So, do you have a null character in your input file? Try passing the input through tr.
tr -d '\0' < inputfile | fold -w30
1,595
Posted By elixir_sinari
Assuming bash/ksh93: datevar=$(tr -d - <...
Assuming bash/ksh93:
datevar=$(tr -d - < /somedirectory/datefile.txt)
echo ${datevar:0:4}
2013
4,070
Posted By elixir_sinari
Using Perl: perl -lne 'print...
Using Perl:
perl -lne 'print +(/\[(.*?)\]/g)[0]' file
Change the subscript to print the required match. Remember that array/list subscripting begins with 0.
2,061
Posted By elixir_sinari
Try using nawk instead of awk. Seems like the...
Try using nawk instead of awk.
Seems like the Solaris awk is accepting only a single-character FS.
820
Posted By elixir_sinari
You seem to be using ksh88, not ksh93. Try: ...
You seem to be using ksh88, not ksh93.
Try:

for i in ab.name.*
do
new=$(echo "$i"|sed 's/^ab/BOX/;s/\./_/g')
echo mv "$i" "$new"
done
820
Posted By elixir_sinari
What shell are you using? Using bash or ksh93: ...
What shell are you using? Using bash or ksh93:
for i in ab.name.*
do
new=${i//./_}
new=${new/#ab/box}
echo mv "$i" "$new"
done
Remove the echo when satisfied with the command lines.
Showing results 1 to 25 of 500

 

Featured Tech Videos

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