Search Results

Search: Posts Made By: elixir_sinari
Forum: What is on Your Mind? 07-19-2016
2,219
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...
5,215
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.
1,571
Posted By elixir_sinari
Try this (with some assumptions): perl -pe...
Try this (with some assumptions):
perl -pe 'BEGIN{$/="ff45"}
$\ = (length >= 7 ? "\n" : "")' file
3,602
Posted By elixir_sinari
In the regex (pattern) part, not the replacement...
In the regex (pattern) part, not the replacement part. I think.
3,602
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?
1,390
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 = () }
}'...
4,287
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
1,024
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.
1,129
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
10,694
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
1,790
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.
1,042
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,640
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...
3,366
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...
3,783
Posted By elixir_sinari
Or fuser.
Or fuser.
3,744
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.
3,744
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...
1,628
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.
3,948
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).
3,948
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
2,728
Posted By elixir_sinari
Assuming bash/ksh93: datevar=$(tr -d - <...
Assuming bash/ksh93:
datevar=$(tr -d - < /somedirectory/datefile.txt)
echo ${datevar:0:4}
2013
9,359
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.
8,514
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.
1,867
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
1,867
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

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