Sponsored Content
Top Forums Shell Programming and Scripting count number of entries perl program or Unix script Post 302635471 by clx on Saturday 5th of May 2012 03:33:19 AM
Old 05-05-2012
Try,

Code:
awk 'NF==2 {a[$1] += $2} NF==3 {a[$1$2] += $3} END { for (i in a) {print i "--" a[i]}}' file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

hw can i count the number of character in a file by perl

i want to count the number of character contained in afile using perl cript help me out (1 Reply)
Discussion started by: trupti_rinku
1 Replies

2. Shell Programming and Scripting

Can you run a unix script from a perl program

Hi all i have a unix script reformatter.sh i have a process whereby this script reformats a file before a perl program is used to update it i am having a little problem automating the entire process . is there a way whereby i can call the unix script from the perl program ? (12 Replies)
Discussion started by: dwightja24
12 Replies

3. UNIX for Dummies Questions & Answers

Unix command to count the number of files with specific characters in name

Hey all, I'm looking for a command that will search a directory (and all subdirectories) and give me a file count for the number of files that contain specific characters within its filename. e.g. I want to find the number of files that contain "-a.jpg" in their name. All the searching I've... (6 Replies)
Discussion started by: murphysm
6 Replies

4. Shell Programming and Scripting

perl script on how to count the total number of lines of all the files under a directory

how to count the total number of lines of all the files under a directory using perl script.. I mean if I have 10 files under a directory then I want to count the total number of lines of all the 10 files contain. Please help me in writing a perl script on this. (5 Replies)
Discussion started by: adityam
5 Replies

5. Shell Programming and Scripting

Help with Unix and Awk to count number of occurrences

Hi, I have a file (movies.sh), this file contains list of movies such as I want to redirect the movies from movies.sh to file_to_process to allow me process the file with out losing anything. I have tried Movies.sh >> file_to_process But I want to add the row number to the data... (2 Replies)
Discussion started by: INHF
2 Replies

6. Homework & Coursework Questions

Script program to count only alphabetical characters

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a shell script program to count the ONLY the number of alphabetic characters stored in the shell variable... (1 Reply)
Discussion started by: kofine05
1 Replies

7. UNIX for Dummies Questions & Answers

Script to count number of rows

Hi, I need a solaris shell script to read multiple files and count number of unique name rows(strings) from those files. The input and output should be like this Input: file 1 abc cde abc ... (9 Replies)
Discussion started by: ssk250
9 Replies

8. UNIX for Dummies Questions & Answers

UNIX - command to count number of files in subdirectories

I have a folder named test/ and under that I have multiple directories and in each of the directory I have multiple log files. I want to know how many files exists under each sub directory. test |--quanrantine |--logfile1 |--logfile2 |--spooling |--logfile1 ... (4 Replies)
Discussion started by: ravikirankethe
4 Replies

9. AIX

UNIX ksh - To print the PID number and repeat count

This question is asked in an interview today that I have to return output with each PID number and the count of each PID number logged today. Here is the script that I have written. Can you confirm if that would work or not. The interviewer didn't said if my answer is correct or not. Can someone... (5 Replies)
Discussion started by: Subodh Kumar
5 Replies

10. UNIX for Beginners Questions & Answers

What script would I use to count the number of a term and its opposite?

Hello All, I am looking to write a script to count the number of a term and its opposite and create a new file with said list. I can get the terms to print to the file but only one or the other and not both. I tried this: grep -wi done */all.txt | grep -wiv done */all.txt > "filename" ... (5 Replies)
Discussion started by: mcesmcsc
5 Replies
SYMLINK(2)						      BSD System Calls Manual							SYMLINK(2)

NAME
symlink, symlinkat -- make symbolic link to a file LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <unistd.h> int symlink(const char *name1, const char *name2); int symlinkat(const char *name1, int fd, const char *name2); DESCRIPTION
A symbolic link name2 is created to name1 (name2 is the name of the file created, name1 is the string used in creating the symbolic link). Either name may be an arbitrary path name; the files need not be on the same file system. The symlinkat() system call is equivalent to symlink() except in the case where name2 specifies a relative path. In this case the symbolic link is created relative to the directory associated with the file descriptor fd instead of the current working directory. If symlinkat() is passed the special value AT_FDCWD in the fd parameter, the current working directory is used and the behavior is identical to a call to symlink(). RETURN VALUES
The symlink() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
The symbolic link succeeds unless: [ENOTDIR] A component of the name2 path prefix is not a directory. [ENAMETOOLONG] A component of the name2 pathname exceeded 255 characters, or the entire length of either path name exceeded 1023 charac- ters. [ENOENT] A component of the name2 path prefix does not exist. [EACCES] A component of the name2 path prefix denies search permission, or write permission is denied on the parent directory of the file to be created. [ELOOP] Too many symbolic links were encountered in translating the name2 path name. [EEXIST] The path name pointed at by the name2 argument already exists. [EPERM] The parent directory of the file named by name2 has its immutable flag set, see the chflags(2) manual page for more infor- mation. [EIO] An I/O error occurred while making the directory entry for name2, or allocating the inode for name2, or writing out the link contents of name2. [EROFS] The file name2 would reside on a read-only file system. [ENOSPC] The directory in which the entry for the new symbolic link is being placed cannot be extended because there is no space left on the file system containing the directory. [ENOSPC] The new symbolic link cannot be created because there is no space left on the file system that will contain the symbolic link. [ENOSPC] There are no free inodes on the file system on which the symbolic link is being created. [EDQUOT] The directory in which the entry for the new symbolic link is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. [EDQUOT] The new symbolic link cannot be created because the user's quota of disk blocks on the file system that will contain the symbolic link has been exhausted. [EDQUOT] The user's quota of inodes on the file system on which the symbolic link is being created has been exhausted. [EIO] An I/O error occurred while making the directory entry or allocating the inode. [EFAULT] The name1 or name2 argument points outside the process's allocated address space. In addition to the errors returned by the symlink(), the symlinkat() may fail if: [EBADF] The name2 argument does not specify an absolute path and the fd argument is neither AT_FDCWD nor a valid file descriptor open for searching. [ENOTDIR] The name2 argument is not an absolute path and fd is neither AT_FDCWD nor a file descriptor associated with a directory. SEE ALSO
ln(1), chflags(2), link(2), lstat(2), readlink(2), unlink(2), symlink(7) STANDARDS
The symlinkat() system call follows The Open Group Extended API Set 2 specification. HISTORY
The symlink() system call appeared in 4.2BSD. The symlinkat() system call appeared in FreeBSD 8.0. BSD
April 10, 2008 BSD
All times are GMT -4. The time now is 12:18 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy