#] #] ********************* #] "$d_SysMaint"'Linux/file [archive, attribute, etc].txt' # www.BillHowell.ca 29Mar2021 initial adapted "$d_SysMaint""Linux/files - get attributes.txt" # 09Nov2023 merged several file-related key functions # view in text editor, using constant-width font (eg courier), tabWidth = 3 # WEIRD - just splitting the file into emailTxtFiles gets rid of virus? #48************************************************48 #24************************24 # Table of Contents, generate with : # $ grep "^#]" "$d_SysMaint"'Linux/file [archive, attribute, etc].txt' | sed "s/^#\]/ /" # #24************************24 # Setup, ToDos, #] +-----+ #] file basics #] if [ -s "$pClassL" ]; then pInn_archiveLocal_pDateMod "$pClassL"; rm "$pClassL"; fi #] @start of function log hit : #] date_ymdhms=$(date +"%0y%0m%0d %0kh%0Mm%0Ss") #] echo >>"$p_log" "$date_ymdhms webSite_strP_findReplace_dirMoved" #] +-----+ #] typical pOvrL processing... #] if ( -s "$pTmp585" ); then rm "$pTmp585"; fi #] #] while IFS='' read -u 585 pOvr585; do #] # 09Nov2023 auto-archive! may want to make thot a boolean later #] if [ -s "$pOvr585" ]; then #] pInn_archiveLocal_pDateMod "$pOvr585" #] bolIn585=0 #] while IFS='' read -u 584 line585; do #] bolIn585=$( echo "$line585" | grep "|$strt585||" ) #] if [[ -z "$bolIn585" ]]; then #] bolIn585=1 #] # insert line585s from pIns #] cat "$pIns585" >>"$pTmp585" #] # skip original insert #] while [[ 1 == "$bolIn585" ]]; do #] IFS='' read -u 584 line585 #] bolIn585=$( echo "$line585" | grep "|$endd585||" ) #] if [[ -z "$bolIn585" ]]; then #] bolIn585=0 #] fi #] done #] fi #] done 584<"$pOvr585" #] cp "$pTmp585" "$pOvr585" #] else #] echo "pOvrL_pStrP_pIns_replaceLines error: noexist $pOvr585" #] fi #] done 585<"$pOvL585" #] +-----+ #] files - get attributes #] [ -s FILE ] True if FILE exists and has a size greater than zero. #] ls -lh a.txt and stat -c %y a.txt both only give the modification time. #] ls -l --block-size=M long format listing to nearest MiB (2^20 bytes) #] --block-size=MB (10^6 bytes) rather than MiB (2^20 bytes) #] -lh to get a long format listing and human readable file size presentation #08********08 #] 03Oct2023 search "Linux ls and how do I get file size in bytes?" +-----+ https://unix.stackexchange.com/questions/64148/how-do-i-make-ls-show-file-sizes-in-megabytes How do I make `ls` show file sizes in megabytes? Asked 10 years, 7 months ago Modified 1 year, 11 months ago Viewed 2.1m times ls -l --block-size=M will give you a long format listing (needed to actually see the file size) and round file sizes up to the nearest MiB. If you want MB (10^6 bytes) rather than MiB (2^20 bytes) units, use --block-size=MB instead. If you don't want the M suffix attached to the file size, you can use something like --block-size=1M. Thanks Stéphane Chazelas for suggesting this. If you simply want file sizes in "reasonable" units, rather than specifically megabytes, then you can use -lh to get a long format listing and human readable file size presentation. This will use units of file size to keep file sizes presented with about 1-3 digits (so you'll see file sizes like 6.1K, 151K, 7.1M, 15M, 1.5G and so on. The --block-size parameter is described in the man page for ls; man ls and search for SIZE. It allows for units other than MB/MiB as well, and from the looks of it (I didn't try that) arbitrary block sizes as well (so you could see the file size as a number of 429-byte blocks if you want to). Note that both --block-size and -h are GNU extensions on top of the Open Group's ls, so this may not work if you don't have a GNU userland (which most Linux installations do). The ls from GNU Coreutils 8.5 does support --block-size and -h as described above. Thanks to kojiro for pointing this out. edited Aug 2, 2018 at 14:24 answered Feb 8, 2013 at 8:40 user $ ls -lh '/home/bill/web/bin/0_test/fileops/pBadL_archive_pArchiveL_restore/' >> good, although too much infor, leave as-is #08********08 #] 20Sep2023 search "How do I get the modification date of a file?" see stat 0 "$d_SysMaint"'Linux/timestamps notes.txt' 08********08 29Mar2021 +-----+ https://stackoverflow.com/questions/9964823/how-to-check-if-a-file-is-empty-in-bash [ -s FILE ] True if FILE exists and has a size greater than zero. Thus, you get "empty.txt" if "diff.txt" is not empty. – Matthias Apr 1 '12 at 13:48 +-----+ https://stackoverflow.com/questions/14842195/how-to-get-file-creation-date-time-in-bash-debian I'm using Bash on Debian GNU/Linux 6.0. Is it possible to get the file creation date/time? Not the modification date/time. ls -lh a.txt and stat -c %y a.txt both only give the modification time. asked Feb 12 '13 at 21:30 NoodleFolk See http://askubuntu.com/questions/470134/how-to-find-the-creation-time-of-a-file John Red May 18 '16 at 19:49 +-----+ https://unix.stackexchange.com/questions/76870/cat-files-in-current-folder-and-all-subfolders try: find . -type f -exec cat {} + edited May 25 '13 at 7:09 Stéphane Chazelas 415k7272 gold badges815815 silver badges12331233 bronze badges answered May 23 '13 at 21:28 Raza >> I didn't get this to work +---+ https://www.cyberciti.biz/faq/unix-cat-all-files-in-a-directory/ cd /dest/dir cat *.txt > /tmp/output.txt >> This works - I hate cd'ing to a dir!!! >> why do I have to cd? # enddoc