UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 4th, 2009, 03:41 AM
patrick chia patrick chia is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 31 patrick chia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 17 m 42 sec
Reputation Power: 1
Command line explanation...

Hi, can anybody explain this command line to me in detail?

The command line is showed as below :
perl -e ' $col1=1; $col2=0; ($f1,$f2)=@ARGV; open(F2,$f2); while (<F2>) { s/\r?\n//; @F=split /\t/, $_; $line2{$F[$col2]} .= "$_\n" }; $count2 = $.; open(F1,$f1); while (<F1>) { s/\r?\n//; @F=split /\t/, $_; $x = $line2{$F[$col1]}; if ($x) { $num_changes = ($x =~ s/^/$_\t/gm); print $x; $merged += $num_changes } } warn "\nJoining $f1 column $col1 with $f2 column $col2\n$f1: $. lines\n$f2: $count2 lines\nMerged file: $merged lines\n"; ' file1 file2 > mergefile1&2

Reply With Quote
  #2  
Old April 4th, 2009, 05:33 AM
ghostdog74 ghostdog74 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 170 ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level)ghostdog74 User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Days 21 h 1 m 7 sec
Reputation Power: 229
firstly, do you have Perl experience? If not, i suggest you start reading up. things like $col=1 is very easy to understand.
secondly, organize the code into different lines, put them in a script and put them in code tags. cramming up perl code in one line like this is poor practice.

Reply With Quote
  #3  
Old April 4th, 2009, 05:43 AM
patrick chia patrick chia is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2009
Posts: 31 patrick chia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 17 m 42 sec
Reputation Power: 1
Quote:
Originally Posted by ghostdog74
firstly, do you have Perl experience? If not, i suggest you start reading up. things like $col=1 is very easy to understand.
secondly, organize the code into different lines, put them in a script and put them in code tags. cramming up perl code in one line like this is poor practice.


Hi, actually I just start learn perl. Thus don't have the experience and enough knowledge to modify the perl provided to get my desired output result.


The command line is at the script showed as below:


perl -e ' $col1=1; $col2=0; ($f1,$f2)=@ARGV; open(F2,$f2); while (<F2>) { s/\r?\n//; @F=split /\t/, $_; $line2{$F[$col2]} .= "$_\n" }; $count2 = $.; open(F1,$f1); while (<F1>) { s/\r?\n//; @F=split /\t/, $_; $x = $line2{$F[$col1]}; if ($x) { $num_changes = ($x =~ s/^/$_\t/gm); print $x; $merged += $num_changes } } warn "\nJoining $f1 column $col1 with $f2 column $col2\n$f1: $. lines\n$f2: $count2 lines\nMerged file: $merged lines\n"; '


You got any better suggestion or command line can get my desired output result?
Thanks a lot for your help and explanation

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Command line explanation...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek