I havent done shell scripting in quite some time. I want to know how to count the number of characters in a word, specifically a parameter.
Example: myscript hello
I want "myscript" to return the number of charcaters in the parameter "hello".
Any ideas? (9 Replies)
I wish to compute the number of dot chars in a string.
Example:
VAR="aaaa.bbbbb.cccc"
I try the shortest command to solve this test.
Thanks in advance for your help.
Regards,
Giovanni (7 Replies)
Hi ..
I am having file say at 53rd position it will be as 0's or 1's .. How can i count the total number of 1's and 0's in the files at the 53 rd location.
Thanks,
Arun (5 Replies)
for example:
i hav a string like :
/rmsprd/arch01/rmsprd/rmsprdarch72736.log
how I can extract
my_num=72736?
I know I can
echo "/rmsprd/arch01/rmsprd/rmsprdarch72736.log" | tr "/" " " | awk '{ print $4 }' to get rmsprdarch72736.log (4 Replies)
I have a file with contents similar to this.
abcd
1234
4567
7666
jdjdjd
89289
9382
92
jksdj
9823
298
I want to write a shell script which count the number of lines that start with the number (disregard the lines starting with alphabets) (1 Reply)
To find out number of "|" symbol is available in file:
Input:
a|b|c|d|z
Ouput:
4
I am using below set of commands,It is working... Anybody have anyother solution using sed / awk.
cnt=`wc -c <1.txt`
cnt1=`tr -d "|" <1.txt >c.dat`
cnt2=`wc -c <c.dat`
outp=`expr $cnt... (19 Replies)
Hi
I am having a 'grep' headache
Here is the contents of my file:
(PBZ,CP,(((ME,PBZ,BtM),ON),((ME,((PBZ,DG),(CW9,PG11))),CW9,TS2,RT1)))
I would like to count out how many times 'PBZ' occurs and then place that number in the line above
3... (8 Replies)
Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count
The input file:
21 2341 A
21 2341 A
21 2341 A
21 2341 C
21 2341 C
21 2341 C
21 2341 C
21 4567 A
21 4567 A
21 4567 C
... (6 Replies)
Hello,
I have some problem in counting char of word, sum and change. I'm not sure shell script can do this.
Input data:
Sam1 BB BB AA AA BB BB BB
Sam2 BB BB AA AA AB AB AB
Sam3 BB BB BB AA BB BB BB
Sam4 AB AB AB AB AB AB AA
Sam5 BB BB AA AA BB BB -- If I count in column 2, B is 9... (3 Replies)
I need to write a BASH script that takes a 2 character string and removes the second character if it is not a digit e.g.
If the string is numberical value >9 e.g. string1 = '34' then leave string1 = '34'.
However if the string is <10 e.g. string1 = '3X' then remove the second char (which... (7 Replies)
Discussion started by: millsy5
7 Replies
LEARN ABOUT MOJAVE
moosex::getopt::meta::attribute
MooseX::Getopt::Meta::Attribute(3pm) User Contributed Perl Documentation MooseX::Getopt::Meta::Attribute(3pm)NAME
MooseX::Getopt::Meta::Attribute - Optional meta attribute for custom option names
VERSION
version 0.59
SYNOPSIS
package App;
use Moose;
with 'MooseX::Getopt';
has 'data' => (
metaclass => 'Getopt',
is => 'ro',
isa => 'Str',
default => 'file.dat',
# tells MooseX::Getopt to use --somedata as the
# command line flag instead of the normal
# autogenerated one (--data)
cmd_flag => 'somedata',
# tells MooseX::Getopt to also allow --moosedata,
# -m, and -d as aliases for this same option on
# the commandline.
cmd_aliases => [qw/ moosedata m d /],
# Or, you can use a plain scalar for a single alias:
cmd_aliases => 'm',
);
DESCRIPTION
This is a custom attribute metaclass which can be used to specify a the specific command line flag to use instead of the default one which
MooseX::Getopt will create for you.
This is certainly not the prettiest way to go about this, but for now it works for those who might need such a feature.
Use 'traits' instead of 'metaclass'
You should rarely need to explicitly set the attribute metaclass. It is much preferred to simply provide a trait (a role applied to the
attribute metaclass), which allows other code to further modify the attribute by applying additional roles.
Therefore, you should first try to do this:
has 'foo' => (traits => ['Getopt'], cmd_flag => 'f');
Custom Metaclass alias
This now takes advantage of the Moose 0.19 feature to support custom attribute metaclass aliases. This means you can also use this as the
Getopt alias, like so:
has 'foo' => (metaclass => 'Getopt', cmd_flag => 'f');
METHODS
cmd_flag
Changes the command-line flag to be this value, instead of the default, which is the same as the attribute name.
cmd_aliases
Adds more aliases for this command-line flag, useful for short options and such.
has_cmd_flag
has_cmd_aliases
AUTHOR
Stevan Little <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2007 by Infinity Interactive, Inc.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.18.2 2013-11-30 MooseX::Getopt::Meta::Attribute(3pm)