How to use S_ISREG() and S_ISDIR() POSIX Macros?

You’re using S_ISREG() and S_ISDIR() correctly, you’re just using them on the wrong thing. In your while((dit = readdir(dip)) != NULL) loop in main, you’re calling stat on currentPath over and over again without changing currentPath: if(stat(currentPath, &statbuf) == -1) { perror(“stat”); return errno; } Shouldn’t you be appending a slash and dit->d_name to currentPath … Read more

equivalent date from GNU to solaris

Tcl has a good free-form date scanner, if you have Tcl installed (try which tclsh). A shell function: tcldate() { d=${1:-now} # the date string f=${2:-%c} # the output format echo “puts [clock format [clock scan {$d}] -format {$f}]” | tclsh } In action on an ancient Solaris 8 box with bash 2.03 and tcl … Read more

Alternative to `sed -i` on Solaris

It isn’t exactly the same as sed -i, but i had a similar issue. You can do this using perl: perl -pi -e ‘s/find/replace/g’ file doing the copy/move only works for single files. if you want to replace some text across every file in a directory and sub-directories, you need something which does it in … Read more

sed edit file in place

The -i option streams the edited content into a new file and then renames it behind the scenes, anyway. Example: sed -i ‘s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g’ filename while on macOS you need: sed -i ” ‘s/STRING_TO_REPLACE/STRING_TO_REPLACE_IT/g’ filename