i wanna ask how to read from a file and give a summery of letter count (separate small than capital letters),number of line ,number of paragraphs,number of quoted sentenses ?
i know the number of lines by (wc -l) but the others i woundered about !! hope somebody teach me :) thx

Dani AI

Generated

Brief recap and practical next steps (builds on original question and the tips from , , and ). For quick counts use the shell utilities for simple checks, but for separate uppercase vs lowercase letters, paragraph detection and quoted‑sentence counting a small script is more reliable (handles Unicode, blank‑line paragraphs, and regex for quoted sentences).

A compact Python example that does the core counts (adjust the regex or use an NLP library if you need more accuracy):

#!/usr/bin/env python3
import sys, re

text = open(sys.argv[1], "r", encoding="utf-8", errors="replace").read()
upper = sum(1 for c in text if c.isupper())
lower = sum(1 for c in text if c.islower())
lines = len(text.splitlines())
paragraphs = len([p for p in re.split(r'\n\s*\n+', text) if p.strip()])
quoted_sentences = len(re.findall(r'["\']([^"\']*?[.!?])["\']', text))

print("Uppercase:", upper)
print("Lowercase:", lower)
print("Lines:", lines)
print("Paragraphs:", paragraphs)
print("Quoted sentences:", quoted_sentences)

Notes: paragraphs are counted as non-empty blocks separated by one or more blank lines; the quoted‑sentence regex is intentionally simple and will miscount abbreviations or nested quotes — use a sentence tokenizer (nltk/spaCy) for production needs.

To find files older than a user date in the current directory without recursing, use find's date tests. For example, to list regular files in the current directory with modification time strictly before 2021-12-31 use a literal-date test and limit depth (ISO dates avoid locale ambiguity). The GNU find manual documents the -newermt and related timestamp tests. (gnu.org)

A caution about “creation time” (birth/crtime): some filesystems (modern ext4, XFS, Btrfs, etc.) and recent kernels expose a creation/birth timestamp via the statx API, and coreutils can show it (stat has %w/%W), but it is not guaranteed on older kernels/toolchains or every filesystem — if birth time is required, verify stat/debugfs/your distro/tooling first or record creation time yourself (xattr, a database, or auditd). See the statx and coreutils docs and the ext4 kernel notes for details. (man7.org)

Recommended Answers

All 6 Replies

I dont think you can do all that using default packages but "wc" do other things then counting lines(-l). run this command: "man wc" and it will teach you :).
You can use "man" for almost every commnd. It gives you the information and almost everything about a command, try that...

Explore options of wc. Hope you found the correct option.

thank you :) its work ;)...
but i wanna ask how to Search the current directory for any files that were created before a given date (as a user input) !!!

I could be wrong, but I don't think any file systems on Linux store the creation date. Though you could check for the modify/change date with the command stat. This code seems to work for me. But the user has to specify the date the same as stat, (yyy-mm-dd).

#!/bin/bash

find . -type f | while read file;
do
modifyDate=`stat $file | grep ^Modify | cut -d' ' -f2`
if [ $1 = $modifyDate ]; then
  echo $file
fi
done;

chris.stout's solution searches every file you've got... icluding those in subdirectories.
Replace his "find . type f" by "ls" and you'll get matching dated files in the current direcory.

ls -ltr
lists the files in the current directory with the latest ones last and including the last modification time. You may be
able to eyeball the date and so the files above that date.

In a script ... there was a trickie way to use find but I forget how it works.

Dumbledor's right. If you wanted to use find, line 3 should be:

find -maxdepth 1 . -type f | while read file;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.