Du without directory and Grep for occurrences of a word
Assistance on work 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:
Files stored in /bin, /sbin, /usr/bin, and /usr/sbin vary in their respective sizes. In fact, there are 244 different sizes if we do not count the zero byte files. Create a command line that proves this and stores the answer, 244, in a files named sizes.txt.
On how many lines does “state” (in any case) appear in any and all of the files in /usr/dict/? Your answer should be a total, not a count per file
2. Relevant commands, code, scripts, algorithms:
See below?
3. The attempts at a solution (include all code and scripts):
du -a /{,usr/}{,s}bin | sort -nu | grep -v ^0 | wc -l > ~/sizes.txt
248
I am close but i cant figure out how or why it counts the directories themselves
These all give me different counts...i know some are looking for just the word state and others occurrences of "state" but i when i do occurrences of "state" its not everyone of them...
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
KeeneStateCollege(KSC), Keene(NH), USA, Charlie W., CS-215-01 Unix
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
Last edited by radoulov; 04-02-2011 at 06:16 PM..
Reason: Code tags!
Here is my grep string to print only the last occurrence, with before and after lines. Note that the tail Argument is sum of B and A args + 1, so that it prints the data of only the last 1 match. Now I need to print last 2 such matches. I thought of doubling the tail arg like 5+5+1 (For -- line),... (2 Replies)
I'm putting together a script that will the count the occurrences of words in text documents. It works fine so far, but I'd like to make a couple tweaks/additions:
1) I'm having a hard time displaying the array index number, tried freq which just spit 0's back at me
2) Is there any way to... (12 Replies)
I was thinking something like this but it always gets rid of the file location.
grep -roh base. | wc -l
find . -type f -exec grep -o base {} \; | wc -l
Would this be a job for awk? Would I need to store the file locations in an array? (3 Replies)
Hi I have the server.log file as:
Server Stopped
ABC
DEF
GHI
JKL
Server Started
MNO
PQR
STU
Server Stopped
VWX
YZ
ABC
Server Started
Server Stopped
123
456
789 (9 Replies)
I am trying to count the occurrences of ALL words in a file. However, I want to exclude certain words: short words (i.e. <3 chars), and words contained in an blacklist file. There is also a desire to count words that are capitalized (e.g. proper names). I am not 100% sure where the line on... (5 Replies)
Hi Everyone,
I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap".
For Example:
In the Directory,
$pwd
/home/nick
$ grep -l "xsgd1234dap" *.sh | wc -l
119
I have "119" files that are still using... (5 Replies)
Hello Everyone!
I trust you are off to a great week! Trying to output the name and count of each uniquely occurring domain in the current directory for a portion of a script I'm building.
Here's what I'm stuck on:
- Need to find UNIQUE occurences of domains (*@domain.com) in ALL files in... (4 Replies)
I am a newbie in UNIX shell script and seeking help on this UNIX function. Please give me a hand. Thanks.
I have a large file. Named as 'MyFile'. It was tab-delmited. I am told to write a shell function that counts the number of occurrences of the ord “mysring” in the file 'MyFile'. (1 Reply)
Hi,
How do i grep unique occurrences from a file.
I have a log file with multiple occurrences of 'foo' for instance. When i do:
grep foo, I get all the lines that contain foo.
Is there any way to get only one line for foo?
Example file:
foo at 09.01am Fri 11 May 2007
foo at 09.13am... (6 Replies)