Search Results

Search: Posts Made By: Tanu
140
Posted By Tanu
Perl/Array Sorting : Can someone please explain below code $h{$_}++
sub uniq {
my %h;
return grep { !$h{$_}++ } @_
}

The above code is to remove duplicates from array.

I am having hard time understanding below things (basically around highlighted...
151
Posted By Tanu
Perl: Can someone please explain this code "sort { $a <=> $b } @unsorted"
@sorted = sort { $a <=> $b } @unsorted;
I am having hard time understanding how this works? I know the output but interested to know the working.


Thanks in advance.
172
Posted By Tanu
@Scrutinizer...
@Scrutinizer (https://www.unix.com/member_modal.php?u=302052697&modal=1) that explains the code well. Thank you very much :)



and I think we also need a \n for expected output :)

awk...
172
Posted By Tanu
Can someone please explain why we need to set ORS in below awk code?
Question: Write a command to print the fields in a text file in reverse order?
awk 'BEGIN {ORS=""} { for(i=NF;i>0;i--) print $i," "; print "\n"}' filename
I was thinking it should be (what is the...
Forum: Programming 07-25-2018
436
Posted By Tanu
just learnt below so updating here - ...
just learnt below so updating here -

super().__init__(value) -- when using super(), no need to pass self

Test.__init__(self,value) -- when using BaseClassName, one needs to pass self too
Forum: Programming 07-23-2018
436
Posted By Tanu
What is wrong with below python inheritance code?
I am using python 3.4. Below is the exception I am getting-

Traceback (most recent call last):
File "./oop.py", line 20, in <module>
y = DerivedClass("Manu")
File "./oop.py", line 15,...
567
Posted By Tanu
Hi Corona688, grep -F -f file1 file2 > file3...
Hi Corona688,

grep -F -f file1 file2 > file3

The above code (added -F) worked really fast for me. I could complete search for a file with 1.5 million records in 5-6 seconds.

Really...
567
Posted By Tanu
Thank you for your reply @Corona688. But I see...
Thank you for your reply @Corona688. But I see the grep command mentioned by you is also running very slow. I am working with files having millions of records.

Let me know if any other way to...
567
Posted By Tanu
Performance Issue for a file search command
Hi All,

This query is regarding performance improvement of a command.

I have a list of IDs in a file (say file1 with single ID column) and file2 has the data rows.

I need to get the IDs...
440
Posted By Tanu
Can I combine below mentioned grep commands using OR (when searching strings having spaces)
Command 1:
$script | grep 'Write to ECC( SSID=MARGIN)'
Command 2:
$script | grep 'is not greater than existing logical processing'

The above commands run my script and search the mentioned...
785
Posted By Tanu
great Thanks. I'll read more about awk built-in...
great Thanks. I'll read more about awk built-in functions.
785
Posted By Tanu
Thanks Ravindra. I had egrep in my code (but...
Thanks Ravindra.

I had egrep in my code (but strange that line was commented).
I did remove it and added escape character (\$0) and it worked.

my @pendJobs =...
785
Posted By Tanu
Agree. Apologies for not providing proper...
Agree. Apologies for not providing proper requirement. Updated my original question.

This latest solution provided by you is not working as well. Error is "grep: write error: Broken pipe"

my...
785
Posted By Tanu
I am using below and it is giving me error-...
I am using below and it is giving me error- egrep: write error: Broken pipe


my @pendJobs = `showStreamsGLIS$reg.$env.ksh | egrep ' OH | OI | RU ' | awk '{sub(/^ +/,X,$0);print}'`;


P.S: I...
785
Posted By Tanu
How do I remove leading spaces in UNIX when count of space character is not fixed? Example below-
Script showStreamsGLIS$reg.$env.ksh gives me output as below-


Job Stime Etime Status ExitCode
GLIS-AS-S-EFL-LOCK-B ----- ----- OI 103313880/0
...
628
Posted By Tanu
Thanks Ravinder. I thought single quotes (' ')...
Thanks Ravinder. I thought single quotes (' ') had some issue in my command but it was \ (as you mentioned).

In perl script it works with \ (like \$1) only but in shell script no need of \ (simple...
628
Posted By Tanu
Please explain the use of quotes in awk command in below example-
Example:

`abc.ksh | grep '^GLIS'| awk -F' ' '{print \$1}'`;
2,214
Posted By Tanu
Thanks R.Singh. I'll make sure I'm using...
Thanks R.Singh. I'll make sure I'm using code/tags for my next posts.
The solution provided by you worked and I have learned something (NF). Cheers :)

---------- Post updated at 04:48 AM...
2,214
Posted By Tanu
How to get 2nd last column of the line- UNIX?
I want to retrieve Status from below example. Columns numbers will be dynamic but Status will always be 2nd last-

JobName StartTime EndTime Status ExitCode

autorep -j $jobName | grep '^FR' |...
2,569
Posted By Tanu
Thanks .. Let me try :) ---------- Post...
Thanks .. Let me try :)

---------- Post updated at 07:18 AM ---------- Previous update was at 06:52 AM ----------

Thanks R.Singh for quick response..your solution worked perfectly (y)
2,569
Posted By Tanu
How to grep a line not starting with # from a file (there are two lines starting with # and normal)?
e.g.

File name: File.txt
cat File.txt
Result:

#INBOUND_QUEUE=FAQ1
INBOUND_QUEUE=FAQ2

I want to get the value for one which is not commented out.

Thanks,
Showing results 1 to 21 of 21

 

Featured Tech Videos

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