Sponsored Content
Full Discussion: How count number of char?
Top Forums Shell Programming and Scripting How count number of char? Post 302839927 by wisecracker on Saturday 3rd of August 2013 06:10:31 PM
Old 08-03-2013
Not sure if this is what you are after but a loop is not required here...

Code:
Last login: Sat Aug  3 22:47:46 on ttys000
AMIGA:barrywalker~> somedata=$(</Users/barrywalker/AudioScope.sh)
AMIGA:barrywalker~> file_length=${#somedata}
AMIGA:barrywalker~> echo "$file_length"
39209
AMIGA:barrywalker~>

If however you want to generste a pseudo "hash number" then that is different...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do I count # of char. in a word?

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)
Discussion started by: xadamz23
9 Replies

2. Shell Programming and Scripting

Number of specific char in a string.

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)
Discussion started by: gio123bg
7 Replies

3. UNIX for Dummies Questions & Answers

how to count pariticular char in a location in a file

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)
Discussion started by: arunkumar_mca
5 Replies

4. Shell Programming and Scripting

how to get number char from a string

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)
Discussion started by: netbanker
4 Replies

5. Shell Programming and Scripting

count the number of lines that start with the number

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)
Discussion started by: grajp002
1 Replies

6. Shell Programming and Scripting

To find number of char occur

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)
Discussion started by: Jairaj
19 Replies

7. UNIX for Dummies Questions & Answers

Grep char count & pipe to sed command

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)
Discussion started by: cavanac2
8 Replies

8. Shell Programming and Scripting

how to add the number of row and count number of rows

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)
Discussion started by: juelillo
6 Replies

9. Shell Programming and Scripting

Count char, sum and change

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)
Discussion started by: awil
3 Replies

10. UNIX for Dummies Questions & Answers

Remove char if not a number

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
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)
All times are GMT -4. The time now is 09:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy