Sponsored Content
Homework and Emergencies Emergency UNIX and Linux Support Sorting file content by file extensions Post 302639669 by otheus on Saturday 12th of May 2012 02:35:31 PM
Old 05-12-2012
Did the OP die of info overload ? Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File name extensions

Hello people, I was wondering if anyone could help me? I want to produce a shell script that changes the filename extension on all matching file. E.G. change all files called ‘something.rtf' to ‘something.doc' by giving the command: Changex rtf doc *where ‘Changex' is the name of... (2 Replies)
Discussion started by: thurrock
2 Replies

2. UNIX for Dummies Questions & Answers

sorting file content on columns

guys i have a question: i'd like to sort files (as many I want) in columns so to visualize them one near the other...so let's say i have just 2 files: FILE1 John Mary Bridget FILE2 Anne Robert Mark i would like to obtain: John Anne Mary Robert Bridget ... (2 Replies)
Discussion started by: marshmallow
2 Replies

3. Shell Programming and Scripting

Sorting Files according to their Extensions...

I am trying to write a Korne Shell Script wherein we have to sort files according to their extensions(for eg. 1.sh, 5.sh, 9.sh together; 4.csh, 120.csh, 6.csh together and 7.ksh, 2.ksh, 59.ksh together) and move them to their respective directories viz. sh, csh and ksh... I think,... (1 Reply)
Discussion started by: marconi
1 Replies

4. Shell Programming and Scripting

Checking file extensions

I am trying to store file with certain file extensions to list but having some problems. Here is a part of the code set fryLst = "" set fxtLst = "" foreach f ($AfullNameLst) set fname = $f:r set fext = $f:e if ("$fext" == ".ry") set fryLst = "$fryLst $f" if ("$fext" == ".xt")... (2 Replies)
Discussion started by: kristinu
2 Replies

5. Shell Programming and Scripting

Sorting content of file

hi ladies and gents: can you give me a command to sort content of file and save it to the file itself: file1 roy@emerson.com joy@emerson.com irish@emerson.com output would be file1 on same directory: file1: irish@emerson.com joy@emerson.com roy@emerson.com (6 Replies)
Discussion started by: linuxgeek
6 Replies

6. Shell Programming and Scripting

Remove comments from file with specific file name extensions

Hello Unix board community, I have to program a shell script, but I am a complete noob so I hope I get some help here. The assignment is as follows: The program removes all comments regardless of formatting or language from files with specific file name extensions (php, css, js, ...).... (3 Replies)
Discussion started by: TheZeusMan
3 Replies

7. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

8. UNIX for Dummies Questions & Answers

Need to exclude certain file extensions while listing the file using ls

Hi friends, I need to check for the latest file say i have list of files like this test_files test_files.1 test_files.2 test_files.3.bin.Z I do it this way ls -lrt test_files*|tail -1 Now i need to exclude test_files.3.bin.Z even if it is the latest file,how do i do... (3 Replies)
Discussion started by: 100bees
3 Replies

9. Shell Programming and Scripting

How to remove exisiting file content from a file and have to append new file content?

hi all, i had the below script x=`cat input.txt |wc -1` awk 'NR>1 && NR<'$x' ' input.txt > output.txt by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

10. Shell Programming and Scripting

List the files after sorting based on file content

Hi, I have two pipe separated files as below: head -3 file1.txt "HD"|"Nov 11 2016 4:08AM"|"0000000018" "DT"|"240350264"|"56432" "DT"|"240350264"|"56432" head -3 file2.txt "HD"|"Nov 15 2016 2:18AM"|"0000000019" "DT"|"240350264"|"56432" "DT"|"240350264"|"56432" I want to list the... (6 Replies)
Discussion started by: Prasannag87
6 Replies
MooseX::MarkAsMethods(3pm)				User Contributed Perl Documentation				MooseX::MarkAsMethods(3pm)

NAME
MooseX::MarkAsMethods - Mark overload code symbols as methods VERSION
This document describes version 0.15 of MooseX::MarkAsMethods - released May 30, 2012 as part of MooseX-MarkAsMethods. SYNOPSIS
package Foo; use Moose; # mark overloads as methods and wipe other non-methods use MooseX::MarkAsMethods autoclean => 1; # define overloads, etc as normal use overload '""' => sub { shift->stringify }; package Baz; use Moose::Role; use MooseX::MarkAsMethods autoclean => 1; # overloads defined in a role will "just work" when the role is # composed into a class; they MUST use the anon-sub style invocation use overload '""' => sub { shift->stringify }; # additional methods generated outside Class::MOP/Moose can be marked, too use constant foo => 'bar'; __PACKAGE__->meta->mark_as_method('foo'); package Bar; use Moose; # order is important! use namespace::autoclean; use MooseX::MarkAsMethods; # ... DESCRIPTION
MooseX::MarkAsMethods allows one to easily mark certain functions as Moose methods. This will allow other packages such as namespace::autoclean to operate without blowing away your overloads. After using MooseX::MarkAsMethods your overloads will be recognized by Class::MOP as being methods, and class extension as well as composition from roles with overloads will "just work". By default we check for overloads, and mark those functions as methods. If "autoclean =&gt; 1" is passed to import on using this module, we will invoke namespace::autoclean to clear out non-methods. TRAITS APPLIED
Using this package causes a trait to be applied to your metaclass (for both roles and classes), that provides a mark_as_method() method. You can use this to mark newly generated methods at runtime (e.g. during class composition) that some other package has created for you. mark_as_method() is invoked with one or more names to mark as a method. We die on any error (e.g. name not in symbol table, already a method, etc). e.g. __PACKAGE__->meta->mark_as_method('newly_generated'); e.g. say you have some sugar from another package that creates accessors of some sort; you could mark them as methods via a method modifier: # called as __PACKAGE__->foo_generator('name', ...) after 'foo_generator' => sub { shift->meta->mark_as_method(shift); }; IMPLICATIONS FOR ROLES
Using MooseX::MarkAsMethods in a role will cause Moose to track and treat your overloads like any other method defined in the role, and things will "just work". That's it. Except... note that due to the way overloads, roles, and Moose work, you'll need to use the coderef or anonymous subroutine approach to overload declaration, or things will not work as you expect. Remember, we're talking about _methods_ here, so we need to make it easy for overload to find the right method. The easiest (and supported) way to do this is to create an anonymous sub to wrap the overload method. That is, this will work: # note method resolution, things will "just work" use overload '""' => sub { shift->stringify }; ...and this will not: use overload '""' => 'stringify'; ...and will result in an error message like: # wah-wah Can't resolve method "???" overloading """" in package "overload" CAVEATS
Roles See the "IMPLICATIONS FOR ROLES" section, above. meta->mark_as_method() You almost certainly don't need or want to do this. CMOP/Moose are fairly good about determining what is and what isn't a method, but not perfect. Before using this method, you should pause and think about why you need to. namespace::autoclean As currently implemented, we run our "method maker" at the end of the calling package's compile scope (B::Hooks::EndOfScope). As namespace::autoclean does the same thing, it's important that if namespace::autoclean is used that it be used BEFORE MooseX::MarkAsMethods, so that its end_of_scope block is run after ours. e.g. # yes! use namespace::autoclean; use MooseX::MarkAsMethods; # no -- overloads will be removed use MooseX::MarkAsMethods; use namespace::autoclean; The easiest way to invoke this module and clean out non-methods without having to worry about ordering is: use MooseX::MarkAsMethods autoclean => 1; SEE ALSO
Please see those modules/websites for more information related to this module. o overload, B::Hooks::EndOfScope, namespace::autoclean, Class::MOP, o Moose. o MooseX::Role::WithOverloading does allow for overload application from o roles, but it does this by copying the overload symbols from the (not o namespace::autoclean'ed role) the symbols handing overloads during class o composition; we work by marking the overloads as methods and letting o CMOP/Moose handle them. SOURCE
The development version is on github at http://github.com/RsrchBoy/moosex-markasmethods <http://github.com/RsrchBoy/moosex-markasmethods> and may be cloned from git://github.com/RsrchBoy/moosex-markasmethods.git <git://github.com/RsrchBoy/moosex-markasmethods.git> BUGS
Please report any bugs or feature requests on the bugtracker website https://github.com/RsrchBoy/moosex-markasmethods/issues When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. AUTHOR
Chris Weyl <cweyl@alumni.drew.edu> COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 by Chris Weyl. This is free software, licensed under: The GNU Lesser General Public License, Version 2.1, February 1999 perl v5.14.2 2012-05-31 MooseX::MarkAsMethods(3pm)
All times are GMT -4. The time now is 08:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy