Unix/Linux Go Back    

Showing results 1 to 25 of 500
Search took 0.09 seconds.
Search: Posts Made By: elixir_sinari
Forum: What is on Your Mind? Linux 07-19-2016
Replies: 12
Views: 1,226
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...
Forum: Shell Programming and Scripting Linux 01-27-2014
Replies: 5
Views: 3,070
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.
Forum: Shell Programming and Scripting Linux 11-10-2013
Replies: 2
Views: 764
Posted By elixir_sinari
Try this (with some assumptions): perl -pe...

Try this (with some assumptions):
perl -pe 'BEGIN{$/="ff45"}
$\ = (length >= 7 ? "\n" : "")' file
Forum: Shell Programming and Scripting Linux 11-08-2013
Replies: 5
Views: 1,766
Posted By elixir_sinari
In the regex (pattern) part, not the replacement...

In the regex (pattern) part, not the replacement part. I think.
Forum: Shell Programming and Scripting Linux 11-08-2013
Replies: 5
Views: 1,766
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?
Forum: Shell Programming and Scripting Linux 11-08-2013
Replies: 3
Views: 807
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 = () }
}'...
Forum: Shell Programming and Scripting Linux 10-23-2013
Replies: 2
Views: 1,103
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
Forum: UNIX for Dummies Questions & Answers Linux 10-07-2013
Replies: 1
Views: 748
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.
Forum: Shell Programming and Scripting Linux 09-21-2013
Replies: 3
Views: 667
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
Forum: Shell Programming and Scripting Linux 09-21-2013
Replies: 5
Views: 5,612
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
Forum: UNIX for Dummies Questions & Answers Linux 09-05-2013
Replies: 3
Views: 822
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.
Forum: Shell Programming and Scripting Linux 07-05-2013
Replies: 2
Views: 601
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...
Forum: UNIX for Dummies Questions & Answers Linux 06-24-2013
Replies: 3
Views: 900
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...
Forum: Shell Programming and Scripting Linux 06-21-2013
Replies: 5
Views: 1,340
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...
Forum: Shell Programming and Scripting Linux 06-21-2013
Replies: 5
Views: 2,198
Posted By elixir_sinari
Or fuser.

Or fuser.
Forum: Shell Programming and Scripting Linux 06-20-2013
Replies: 7
Views: 996
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.
Forum: Shell Programming and Scripting Linux 06-20-2013
Replies: 7
Views: 996
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...
Forum: Shell Programming and Scripting Linux 06-16-2013
Replies: 9
Views: 776
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.
Forum: Shell Programming and Scripting Linux 06-14-2013
Replies: 8
Views: 2,267
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).
Forum: Shell Programming and Scripting Linux 06-14-2013
Replies: 8
Views: 2,267
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
Forum: UNIX for Dummies Questions & Answers Linux 06-13-2013
Replies: 3
Views: 1,431
Posted By elixir_sinari
Assuming bash/ksh93: datevar=$(tr -d - <...

Assuming bash/ksh93:
datevar=$(tr -d - < /somedirectory/datefile.txt)
echo ${datevar:0:4}
2013
Forum: Shell Programming and Scripting Linux 06-12-2013
Replies: 7
Views: 2,770
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.
Forum: Shell Programming and Scripting Linux 06-12-2013
Replies: 7
Views: 1,205
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.
Forum: Shell Programming and Scripting Linux 06-12-2013
Replies: 6
Views: 707
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
Forum: Shell Programming and Scripting Linux 06-11-2013
Replies: 6
Views: 707
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 10:19 PM.