Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] Count amount of times of appearing of character before a word? Post 302630515 by FUTURE_EINSTEIN on Thursday 26th of April 2012 12:58:01 AM
Old 04-26-2012
[Solved] Count amount of times of appearing of character before a word?

Hello Is there a way to calculate how many times a particular symbol appeared in a string before a particular word.
Code:
 Desktop/Myfiles/pet/dog/puppy

So, I want to count number of occurence of"/" in this directory before the word dog lets say.
Cheers,

Bob
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed X amount of times - X is dynamic

I'm trying to make a bash shell script that will allow a user to modify another file based on input they give. Maybe someone can see what I'm doing wrong here. I'm still pretty new at this... Let's say my temp file contains this: 0 1 HELLO 3 4 And here's the code: old=(0 1 3 4) new=(zero... (2 Replies)
Discussion started by: Loriel
2 Replies

2. UNIX for Dummies Questions & Answers

count amount of accounts?

Hi, I am relatively new to Unix and trying to understand as much as I can. I would like to know if it's possible to count the total number of Unix accounts? If so, can the count be done from any working directory or does it have to be specific to where the accounts are based? Thanks! (4 Replies)
Discussion started by: Trogan
4 Replies

3. Shell Programming and Scripting

Looking for a single line to count how many times one character occurs in a word...

I've been looking on the internet, and haven't found anything simple enough to use in my code. All I want to do is count how many times "-" occurs in a string of characters (as a package name). It seems it should be very simple, and shouldn't require more than one line to accomplish. And this is... (2 Replies)
Discussion started by: Shingoshi
2 Replies

4. Shell Programming and Scripting

scripting - write a script that will count the number of times a particular word

hello everyone, I'm trying to learn some scripts but i cant get my head around two of them. 1. how can i write a script that will count the number of times a particular word is used in file? 2. how can i make a script that will take me to a web page from unix? if anyone could help it... (3 Replies)
Discussion started by: BigTool4u2
3 Replies

5. Shell Programming and Scripting

How to format a character to look like an amount -solved

Hi All, I want to format the retrieved varchar2 value in the database to $9,999,999,990.00 but remained as a character value. Is it possible? Example: 378273.23 to $378,273.23 below is the code i want to implement: sqlplus -s ${USERNAME}/${PASSWORD}@${ORACLE_SID} << END1 >> $LOGFILE... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

6. UNIX for Advanced & Expert Users

Count specific word or character per line

Hi, I need help regarding counting specific word or character per line and validate it against a specific number i.e 10. And if number of character equals the specific number then that line will be part of the output. Specific number = 6 Specific word or char = || Sample data:... (1 Reply)
Discussion started by: janzper
1 Replies

7. UNIX for Dummies Questions & Answers

how to count number of times each word exist in a file

I'm trying to count the number of times each word in the file exist for example if the file has: today I have a lot to write, but I will not go for it. The main thing is that today I am looking for a way to get each word in this file with a word count after it specifying that this word has... (4 Replies)
Discussion started by: shnkool
4 Replies

8. UNIX for Dummies Questions & Answers

How do I count how many times a specific word appear in a file (ksh)?

Hi Please can you help how do I count the number of specific characters or words that appear in a file? (8 Replies)
Discussion started by: fretagi
8 Replies

9. Shell Programming and Scripting

Count same word which has come many times in single lines & pars

can i get a simple script for , Count same word which has come many times in single lines & pars Eg file would be == "Thanks heman thanks thanks Thanks heman thanks man" So resullt should be Thanks = 5 heman=2 man = 1 thanks in advance :) Please use code tags for code and... (1 Reply)
Discussion started by: heman96
1 Replies

10. UNIX for Dummies Questions & Answers

[Solved] Awk: count occurrence of each character for every field

Hi, let's say an input looks like: A|C|C|D A|C|I|E A|B|I|C A|T|I|B as the title of the thread explains, I am trying to get something like: 1|A=4 2|C=2|B=1|T=1 3|I=3|C=1 4|D=1|E=1|C=1|B=1 i.e. a count of every character in each field (first column of output) independently, sorted... (4 Replies)
Discussion started by: beca123456
4 Replies
String::Errf(3pm)					User Contributed Perl Documentation					 String::Errf(3pm)

NAME
String::Errf - a simple sprintf-like dialect VERSION
version 0.006 SYNOPSIS
use String::Errf qw(errf); print errf "This process was started at %{start}t with %{args;argument}n. ", { start => $^T, args => 0 + @ARGV }; ...might print something like: This process was started at 2010-10-17 14:05:29 with 0 arguments. DESCRIPTION
String::Errf provides "errf", a simple string formatter that works something like "sprintf". It is implemented using String::Formatter and Sub::Exporter. Their documentation may be useful in understanding or extending String::Errf. DIFFERENCES FROM SPRINTF
The data passed to "errf" should be organized in a single hashref, not a list. Formatting codes require named parameters, and the available codes are different. See "FORMATTING CODES" below. As with most String::Formatter formatters, "%" is not a format code. If you want a literal "%", do not put anything between the two percent signs, just write "%%". FORMATTING CODES "errf" formatting codes require a set of arguments between the "%" and the formatting code letter. These arguments are placed in curly braces and separated by semicolons. The first argument is the name of the data to look for in the format data. For example, this is a valid use of "errf": errf "The current time in %{tz}s is %{now;local}t.", { tz => $ENV{TZ}, now => time, }; The second argument, if present, may be a compact form for multiple named arguments. The rest of the arguments will be named values in the form "name=value". The examples below should help clarify how arguments are passed. When an argument appears in both a compact and named form, the named form trumps the compact form. The specific codes and their arguments are: s for string The "s" format code is for any string, and takes no arguments. It just includes the named item from the input data. errf "%{name}s", { name => 'John Smith' }; # returns "John Smith" Remember, "errf" does not have any of the left- or right-padding formatting that "sprintf" provides. It is not meant for building tables, only strings. i for integer The "i" format code is used for integers. It takes one optional argument, "prefix", which defaults to the empty string. "prefix" may be given as the compact argument, standing alone. "prefix" is used to prefix non-negative integers. It may only be a plus sign. errf "%{x}i", { x => 10 }; # returns "10" errf "%{x;+}i", { x => 10 }; # returns "+10" errf "%{x;prefix=+}i", { x => 10 }; # returns "+10" The rounding behavior for non-integer values is not currently specified. f for float (or fractional) The "f" format code is for numbers with sub-integer precision. It works just like "i", but adds a "precision" argument which specifies how many decimal places of precision to display. The compact argument may be just the prefix or the prefix followed by a period followed by the precision. errf "%{x}f", { x => 10.1234 }; # returns "10"; errf "%{x;+}f", { x => 10.1234 }; # returns "+10"; errf "%{x;.2}f", { x => 10.1234 }; # returns "10.12"; errf "%{x;+.2}f", { x => 10.1234 }; # returns "+10.12"; errf "%{x;precision=.2}f", { x => 10.1234 }; # returns "10.12"; errf "%{x;prefix=+;precision=.2}f", { x => 10.1234 }; # returns "+10.12"; t for time The "t" format code is used to format timestamps provided in epoch seconds. It can be given two arguments: "type" and "tz". "type" can be either date, time, or datetime, and indicates what part of the timestamp should be displayed. The default is datetime. "tz" requests that the timestamp be displayed in either UTC or the local time zone. The default is local. The compact form is just "type" alone. # Assuming our local time zone is America/New_York... errf "%{x}t", { x => 1280530906 }; # "2010-07-30 19:01:46" errf "%{x;type=date}t", { x => 1280530906 }; # "2010-07-30" errf "%{x;type=time}t", { x => 1280530906 }; # "19:01:46" errf "%{x;type=datetime}t", { x => 1280530906 }; # "2010-07-30 19:01:46" errf "%{x;tz=UTC}t", { x => 1280530906 }; # "2010-07-30 23:01:46 UTC" errf "%{x;tz=UTC;type=date}t", { x => 1280530906 }; # "2010-07-30 UTC" errf "%{x;tz=UTC;type=time}t", { x => 1280530906 }; # "23:01:46 UTC" errf "%{x;tz=UTC;type=datetime}t", { x => 1280530906 }; # "2010-07-30 23:01:46 UTC" n and N for numbered The "n" and "N" format codes are for picking words based on number. It takes two of its own arguments, "singular" and "plural", as well as "prefix" and "precision" which may be used for formatting the number itself. If the value being formatted is 1, the singular word is used. Otherwise, the plural form is used. errf "%{x;singular=dog;plural=dogs}n", { x => 0 }; # 0 dogs errf "%{x;singular=dog;plural=dogs}n", { x => 1 }; # 1 dog errf "%{x;singular=dog;plural=dogs}n", { x => 2 }; # 2 dogs errf "%{x;singular=dog;plural=dogs}n", { x => 1.4 }; # 1.4 dogs errf "%{x;singular=dog;plural=dogs;precision=1}n", { x => 1.4 }; # 1.4 dogs errf "%{x;singular=dog;plural=dogs;precision=0}n", { x => 1.4 }; # 1 dog If "N" is used instead of "n", the number will not be included, only the chosen word. errf "%{x;singular=is;plural=are}N", { x => 0 }; # are errf "%{x;singular=is;plural=are}N", { x => 1 }; # is errf "%{x;singular=is;plural=are}N", { x => 2 }; # are errf "%{x;singular=is;plural=are}N", { x => 1.4 }; # 1.4 are errf "%{x;singular=is;plural=are;precision=1}N", { x => 1.4 }; # 1.4 are errf "%{x;singular=is;plural=are;precision=0}N", { x => 1.4 }; # 1 is The compact form may take any of the following forms: word - equivalent to singular=word word+suffix - equivalent to singular=word;plural=wordsuffix word1/word2 - equivalent to singular=word;plural=word2 If no singular form is given, an exception is thrown. If no plural form is given, one will be generated according to some basic rules of English noun orthography. AUTHOR
Ricardo Signes <rjbs@cpan.org> COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Ricardo Signes. 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.12.3 2010-10-29 String::Errf(3pm)
All times are GMT -4. The time now is 04:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy