12-17-2010
AWK - number of specified characters in a string
Hello,
I'm new to using AWK and would be grateful for some basic advice to get me started.
I have a file consisting of 10 fields. Initially I wish to calculate the number of . , ~ and ^ characters in the 9th field ($9) of each line. This particular string also contains alphabetical characters. Lets call this value "count". I presume the length function would be used here, but am unsure how to specify multiple criteria.
I'd then like to create a new field at the end of each line that equals count/$8.
Finally I'd like to save this as a new file.
Many thanks,
Olly
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am trying out different scripts in PERL. I want to take a line/string as an input from the user and count the number of occurrances of all the alphabets (a..z) in the string. I tried doingit like this :
#! /opt/exp/bin/perl
print "Enter a string or line : ";
$string = <STDIN>;
chop... (5 Replies)
Discussion started by: rsendhilmani
5 Replies
2. Programming
i have a string "dfasdfasdfadf"
i want to count the number of times each character is repeated..
For instance, d is repeated 4 times, f is repeated 4 times..
can u give a program in c (1 Reply)
Discussion started by: pgmfourms
1 Replies
3. Shell Programming and Scripting
Hi there, I have some user input in a variable called $VAR, and i need to ensure that the string is 5 or less characters .... does anybody know how i can count the characters in the variables ?
any help would be great, cheers (2 Replies)
Discussion started by: rethink
2 Replies
4. Shell Programming and Scripting
Hello all,
I have the following problem:
My input is two sorted files:
file1
>1_19_130_F3
T01220131330230213311013000000110000
>1_23_69_F3
T01200211300200200010000001000000
>1_24_124_F3
T010203113002002111111200002010
file2
>1_19_130_F3
24 18 9 18 23 4 11 4 5 9 5 8 15 20 4 4 7 4... (9 Replies)
Discussion started by: DerSeb
9 Replies
5. Shell Programming and Scripting
This is my problem, my file (file A) contains the following information:
Now, I would like to create a file (file B) containing only the lines with 10 or more characters but less than 20 with their corresponding ID:
Then, I need to compare the entries and determine their frequency. Thus, I... (7 Replies)
Discussion started by: Xterra
7 Replies
6. Shell Programming and Scripting
Hello:
I have a large file which contains lines like the following:
1/t123ab, &Xx:1:1234:12345:123456@ABCDEFG... at -$100.00%
/t is a tab, spaces are as indicated
the string "&Xx:1:1234:12345:123456$ABCDEFG..." has a slightly variable number of numbers and letters, but it always starts... (9 Replies)
Discussion started by: Tectona
9 Replies
7. Shell Programming and Scripting
Hi Experts,
How to sepearate the list digit with letters : with a space from where the letters begins, or other words from where the digits ended.
file
52087mo(enbatl)
52049mo(enbatl)
52085mo(enbatl)
25051mo(enbatl)
The output should be looks like:
52087 mo(enbatl)
52049... (10 Replies)
Discussion started by: rveri
10 Replies
8. Shell Programming and Scripting
Hi I have a source file that looks like
a,b,c,d,e,f,g,h,t,DISTI(USD),MSRP(USD),DIST(EUR),MSRP(EUR),EMEA-DISTI(USD),EMEA-MSRP(USD),GLOBAl-DISTI(USD),GLOBAL-MSRP(USD),DISTI(GBP), MSRP(GBP)
I want to basically change MSRP(USD) to MSRP,USD and DIST(EUR) to DIST,EUR and likewise for all i'm using... (3 Replies)
Discussion started by: r_t_1601
3 Replies
9. Shell Programming and Scripting
I have the following script that will print column 4 ("25") when column 1 contains "123". However, I need to ignore the alpha characters that are contained in the input file. If I were to ignore the characters my output would be column 3.
What is the best way to print my column of interest... (3 Replies)
Discussion started by: ncwxpanther
3 Replies
10. UNIX for Beginners Questions & Answers
I have below code inside my awk script
if ( $0 ~ /SVC IN:/ )
{
svc_in=substr( $0,23 , 3);
if (msg_start == 1 && msg_end == 0)
{
msg_arr=$0;
}
}
else if ( $0 ~ /^SVC OUT:/ )
{
svc_out=substr( $0, 9, 3);
if (msg_start == 1 && msg_end == 0)
... (6 Replies)
Discussion started by: bhagya123
6 Replies
LEARN ABOUT SUSE
uuencode
UUENCODE(5) File Formats Manual UUENCODE(5)
NAME
uuencode - format of an encoded uuencode file
DESCRIPTION
Files output by uuencode(1) consist of a header line, followed by a number of body lines, and a trailer line. The uudecode(1) command will
ignore any lines preceding the header or following the trailer. Lines preceding a header must not, of course, look like a header.
The header line is distinguished by having the first 6 characters begin The word begin is followed by a mode (in octal), and a string
which names the remote file. A space separates the three items in the header line.
The body consists of a number of lines, each at most 62 characters long (including the trailing newline). These consist of a character
count, followed by encoded characters, followed by a newline. The character count is a single printing character, and represents an inte-
ger, the number of bytes the rest of the line represents. Such integers are always in the range from 0 to 63 and can be determined by sub-
tracting the character space (octal 40) from the character.
Groups of 3 bytes are stored in 4 characters, 6 bits per character. All are offset by a space to make the characters printing. The last
line may be shorter than the normal 45 bytes. If the size is not a multiple of 3, this fact can be determined by the value of the count on
the last line. Extra garbage will be included to make the character count a multiple of 4. The body is terminated by a line with a count
of zero. This line consists of one ASCII space.
The trailer line consists of end on a line by itself.
SEE ALSO
uuencode(1), uudecode(1), uusend(1), uucp(1), mail(1)
HISTORY
The uuencode file format appeared in BSD 4.0 .
UUENCODE(5)