Linux.org User-created Helpful Shell Scripts

Here's a sed script that takes large numbers (from the thousands to anything less than ten trillion) and puts
commas where they should be:

Code:
#trillions
s/\([0-9]\)\([0-9]\{3\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2,\3,\4,\5/g

#hundred billions
s/\([0-9]\{3\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2,\3,\4/g

#ten billions
s/\([0-9]\{2\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2,\3,\4/g

#billions
s/\([0-9]\)\([0-9]\{3\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2,\3,\4/g

#hundred millions
s/\([0-9]\{3\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2,\3/g

#ten millions
s/\([0-9]\{2\}\)\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2,\3/g

#millions
s/\([0-9]\)\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2,\3/g

#hundred thousands
s/\([0-9]\{3\}\)\([0-9]\{3\}\)/\1,\2/g

#ten thousands
s/\([0-9]\{2\}\)\([0-9]\{3\}\)/\1,\2/g

#one thousands
s/\([0-9]\)\([0-9]\{3\}\)/\1,\2/g

I got the idea to do something like this because in a couple of the books i've read, the authors mention ways to put commas between large numbers, but i haven't seen anything that would apply that to anything that comes from the command line output:


Code:
xarathustra@xarathustra:~$ df | sed -f easy-numbers.sed
Filesystem      1K-blocks      Used  Available Use% Mounted on
tmpfs             1,565,544      3,292    1,562,252   1% /run
/dev/nvme0n1p2  805,437,640 421,062,300  343,387,900  56% /
tmpfs             7,827,708     23,812    7,803,896   1% /dev/shm
tmpfs                5,120         4       5,116   1% /run/lock
/dev/nvme0n1p1     523,248      5,364     517,884   2% /boot/efi
tmpfs             1,565,540       148    1,565,392   1% /run/user/1,000
/dev/nvme0n1p4 1,093,885,756   5,293,096 1,032,952,596   1% /media/xarathustra/4f763,174-e291-489a-9b8d-e418f7b70fa1
/dev/nvme0n1p3   19,982,160  15,252,016    3,689,760  81% /media/xarathustra/9d485,139-229e-4f36-ade2-d

Of course, it jumbles the columns from the df program, so you would need some code from awk to make this look neater...but my script does work to accomplish its intention.
LMFAO, how humiliating...when i wrote that script, i didn't think you could do flow control in sed...but not only can you do flow control in sed, there's a MUCH simpler way to put commas in large numbers:


Even the code that page is more verbose that it needs to be:

Code:
:loop
s/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/
t loop

Compare that to the absurd amout of typing i did in my script above :p Interestingly enough though, the script i made [in the last post] works for quadrillions as well even though i didn't specify a number with that many zeroes in the script, i wonder why...
 


Here's a simple script for recording your computer's temperatures, you must install lm-sensors for this to work:

Code:
#!/bin/bash
#records CPU/mobo temps over a period of time
t=1

while true; do
    sleep 60
    echo -e "\n$t MINUTE(S):\n"
    sensors | sed '/+/!d;s/(.*//g;/^$/d'
    ((++t))
done

I made it cuz today i've been gaming and i would like to know how hot my computer gets when i do it. You can add redirection if you want it to go to a file instead of the terminal.
 
In a different thread i complained that i don't like the way the output looks in the "comm" and "diff" commands, so i decided to make scripts that makes the output look more in line with my preferemces. The first one just compares two files side by side, the second one looks for unique lines in each of the files despite where they are:
Code:
#!/bin/bash
#easier to read format for showing differences between files

#tells user how to use script
SCRIPT=$0

if [ $# -lt 2 ]; then
        echo "This script needs two files as arguments: ${SCRIPT##*/} file file2"
        exit 1
fi

if ! [ -f $1 ] || ! [ -f $2 ]; then
        echo "File or files do not exist."
        exit 2
fi

#assings lines to arrays
readarray -t DIFF < $1
readarray -t DIFF2 < $2

echo -e "Different lines in $1:\n"
#loops non-matching lines in an array plus their line number from first file
count=${#DIFF[@]}
for (( j=0; j<count; j++ )); do
        line_numb=$((j + 1))
        if [ "${DIFF[j]}" != "${DIFF2[j]}" ]; then
                echo "(Line $line_numb)"
                echo "${DIFF[j]}"
        fi
done

#loops non-matching lines in an array from their line number from second file
echo -e "\nDifferent lines in $2:\n"
count2=${#DIFF2[@]}
for (( j=0; j<count2; j++ )); do
        line_numb=$((j + 1))
        if [ "${DIFF[j]}" != "${DIFF2[j]}" ]; then
                echo "(Line $line_numb)"
                echo "${DIFF2[j]}"
        fi
done

Code:
#!/bin/bash
#easier to read format for showing differences between files

SCRIPT=$0

if [ $# -lt 2 ]; then
        echo "This script needs two files as arguments: ${SCRIPT##*/} file file2"
fi

if ! [ -f $1 ] || ! [ -f $2 ]; then
        echo "File or files do not exist."
fi

echo -e "These lines are unique to $1:\n"

diff --new-line-format="" --unchanged-line-format="" <(sort $1) <(sort $2)

echo -e "\n"

echo -e "These lines are unique to $2:\n"

diff --new-line-format="" --unchanged-line-format="" <(sort $2) <(sort $1)
 
I think it's unfortunate that i am the only person who keeps posting in this thread...but here is my final version of my script for looking at comparisons...i think it's best if you just use mandatory options to control what it outputs rather than a user prompt, this one allows you to either display completely unique lines, compare them side by side (with line number), the lines in the files that are the same, or the options together. Leading blanks are removed from temporary files use for script because they don't make any difference in terms of error checking in code anyway, which is what this script is meant for. Also, blank lines in the output are removed as well.
Code:
#!/bin/bash
#easier to read format for showing differences between files

SCRIPT=$0
#instructions in how to use script
if [ $# -lt 3 ]; then
        echo "Usage: ${SCRIPT##*/} -[option(s)] file file2"
        echo "option -u: print unique lines in documents"
        echo "option -c: print different lines side-by-side"
        echo "option -s: print lines that are the same side-by-side"
        exit
fi

if ! [[ "$1" =~ ^-[ucs] ]]; then
        echo "Usage: ${SCRIPT##*/} -[option(s)] file file2"
        echo "-u option: print unique lines in documents"
        echo "-c option: print different lines side-by-side"
        echo "-s option: print lines that are the same side-by-side"
        exit
fi
#error if file doesn't exist
if ! [ -f "$2" ] || ! [ -f "$3" ]; then
        echo "File or files do not exist."
        exit 2
fi

sed 's/^[ \t]*//g' $2 > temp-diff
sed 's/^[ \t]*//g' $3 > temp-diff2

#assigns lines from file to arrays
readarray -t DIFF < temp-diff
readarray -t DIFF2 < temp-diff2

#if $1 contains "-u", then print unique lines
if [[ "$1" = "-"*"u"* ]]; then
        echo -e "These lines are unique to $2:\n"
        diff --new-line-format="" --unchanged-line-format="" <(sort temp-diff) <(sort temp-diff2) | sed '/^$/d'
        echo -e "\nThese lines are unique to $3:\n"
        diff --new-line-format="" --unchanged-line-format="" <(sort temp-diff2) <(sort temp-diff) | sed '/^$/d'
fi

#if $1 contains "-c", then compare side by side
if [[ "$1" = "-"*"c"* ]]; then
        echo -e "Different lines in $1:\n"
        #loops non-matching lines in an array plus their line number from first file
        count=${#DIFF[@]}
        for (( j=0; j<count; j++ )); do
                line_numb=$((j + 1))
                if [ "${DIFF[j]}" != "${DIFF2[j]}" ]; then
                        echo "${DIFF[j]} (Line $line_numb)"
                fi
        done | sed '/^$/d'

        #loops non-matching lines in an array from their line number from second file
        echo -e "\nDifferent lines in $2:\n"
        count2=${#DIFF2[@]}
        for (( j=0; j<count2; j++ )); do
                line_numb=$((j + 1))
                if [ "${DIFF[j]}" != "${DIFF2[j]}" ]; then
                        echo "${DIFF2[j]} (Line $line_numb)"
                fi
        done | sed '/^$/d'

fi

#if line contains "-s", then display lines that are the same when compared side by side
if [[ "$1" = "-"*"s"* ]]; then
        echo -e "\nThese lines are exactly the same in both:\n"
        count3=${#DIFF[@]}
        for (( j=0; j<count3; j++ )); do
                if [ "${DIFF[j]}" = "${DIFF2[j]}" ] && [ -n "${DIFF2[j]}" ]; then
                        echo "${DIFF[j]}"
                fi
        done
fi

#remove files used to create arrays earlier
rm temp-diff temp-diff2

EDIT: Checking which lines are the same didn't work because my variable for the loop limit count3=${#DIFF[@]} did not match the variable in the loop, i have changed it to work correctly.
 
Last edited by a moderator:
I’ve added links to some of my scripts.
I’ve got some more scripts that I plan to publish soon. I just need to find time to clean them up and document them - add man-pages and license text etc.
Once they’re ready, I’ll publish then to my notabug account (basically an alternative to github), then I’ll put a post here.

I’ll also add a post to this thread with links to a couple of really useful scripts from @iridakos, who hasn’t been active here for a while.
 
Here's that timer script talked about earlier from linux-config.org but enabled to be able to countdown seconds and hours, and lets you select something for the robot to say when the time runs out!

Code:
read -p "What do you want the robot to say when time runs out? " string

if [ "$#" -lt "2" ] ; then
        echo "Incorrect usage ! Example:"
        echo './countdown.sh -d  "Jun 10 2011 16:06"'
        echo 'or'
        echo './countdown.sh -m  90'
        exit 1
fi

now=`date +%s`

if [ "$1" = "-d" ] ; then
        until=`date -d "$2" +%s`
        sec_rem=`expr $until - $now`
        echo "-d"
        if [ $sec_rem -lt 1 ]; then
                echo "$2 is already history !"
        fi
fi
if [ "$1" = "-m" ] ; then
        until=`expr 60 \* $2`
        until=`expr $until + $now`
        sec_rem=`expr $until - $now`
        echo "-m"
        if [ $sec_rem -lt 1 ]; then
                echo "$2 is already history !"
        fi
fi
if [ "$1" = "-s" ] ; then
        until=`expr $2`
        until=`expr $until + $now`
        sec_rem=`expr $until - $now`
        echo "-m"
        if [ $sec_rem -lt 1 ]; then
                echo "$2 is already history !"
        fi
fi
if [ "$1" = "-h" ] ; then
        until=`expr $2 \* 60 \* 60`
        until=`expr $until + $now`
        sec_rem=`expr $until - $now`
        echo "-m"
        if [ $sec_rem -lt 1 ]; then
                echo "$2 is already history !"
        fi
fi

_R=0
_C=7
tmp=0
percent=0
total_time=0
col=`tput cols`
col=$(( col -5 ))

while [ $sec_rem -gt 0 ]; do
        #clear allows for progress to keep changing on screen
        clear
        #shows date at top of screen
        date
        #variable that subtracts one second each llop
        let sec_rem=$sec_rem-1
        #variable for remaining time
        interval=$sec_rem
        #variable containing remaining number of seconds within each minute with modulo
        #for remainder
        seconds=`expr $interval % 60`
        #subtracts remaining seconds from interval
        interval=`expr $interval - $seconds`
        #shows remaining minutes within hour by dividing total seconds by 3600 with
        #remainder and then dividing by 60, shows minutes from seconds
        minutes=`expr $interval % 3600 / 60`
        interval=`expr $interval - $minutes`
        hours=`expr $interval % 86400 / 3600`
        interval=`expr $interval - $hours`
        days=`expr $interval % 604800 / 86400`
        interval=`expr $interval - $hours`
        weeks=`expr $interval / 604800`
        echo "----------------------------"
        echo "Seconds: " $seconds
        echo "Minutes: " $minutes
        echo "Hours:   " $hours
        echo "Days:    " $days
        echo "Weeks:   " $weeks

        echo -n "["

        progress=$((progress + 1))
        if [ $total_time -lt 1 ] ; then
                total_time=$((hours * 3600 + minutes * 60 + seconds))
        fi

        printf -v f "%$(echo $_R)s>" ; printf "%s\n" "${f// /=}"
        _C=7
        tput cup 7 $col

        tmp=$percent
        percent=$((progress * 100 / total_time))
        printf "]%d%%" $percent
        change=$((percent - $tmp))

        _R=$(( col * percent / 100 ))
    #sleep 1 is what makes script into a valid timer, otherwise the script would quickly run itself out
        sleep 1
done

printf "\n"

while true; do
        spd-say "$string"
        sleep 600
done
 
I still haven't got around to cleaning up my scripts for publication, but here are two really useful scripts by fellow Linux.org user @iridakos, who hasn't been active much recently.

First up:
goto (official github) - Goto allows you to define and manage shortcuts/aliases in the terminal for directories you use often, so you can quickly navigate to them.
So for example you can add/register a shortcut using goto -r /path/to/directory shortcut
Where /path/to/directory is the path to the directory you want to create a shortcut to.
and shortcut is the name of the shortcut.

And then you use the shortcut like this: goto shortcut and goto will take you straight to that directory.

There are also options for deleting/unregistering shortcuts, listing shortcuts, expanding them, cleaning up invalid/non-existent directory aliases (for example, if you've deleted a directory that you have a shortcut to, you run goto -c and it will automatically remove aliases for non existent directories.
For help with goto and to see all of the options, use goto -h, or goto --help.

Here's @iridakos 's original post, from when goto was first published/released:
https://linux.org/threads/goto-a-bash-utility-to-navigate-to-aliased-directories.16647/

Finally:
stup (official github) - short for standup - Stup is a great tool for any developers who are using the agile/scrum development methodology.
Stup allows you to make and organise daily notes, ready for your next "Daily scrum", or "standup" meeting.
I use it alongside my own terminal based note application (see this earlier post in this thread).
I use my note application for dealing with any random/general notes that I want to take.
And I use stup for logging my day to day activities and notes, to ensure I'm always prepared for my development teams next "daily scrum"/ standup meeting.
Stup has a lot of different options too. So check out stup -h, or stup --help.

Here's @iridakos 's original post, from when stup was first published/released:
https://linux.org/threads/cli-for-daily-notes.28774/

Two extremely useful scripts that I use all of the time, created by fellow linux.org member @iridakos.
Highly recommended!
 
Last edited:
In "wicked shell scripts", there's a script for determining whether or not a program is executable or not, and it doesn't work. I think it's because there aren't quotes where there should be. Anyways, i thought that was a good idea so i made my own that has more features and works:

Code:
#!/bin/bash
#script idea: tell user if a file is executable or is included in path

SCRIPT=$0

#instructions
if [ $# -lt 1 ]; then
    echo "Usage:${SCRIPT##*/} [program-name]"
fi

#creates file listing path directories
echo $PATH | awk 'BEGIN {RS=":"} {print}' | sed '/^$/d' > path-dirs

#loops through directories and tells user if file exists but is not executable
while read -r line; do
    if [ -f "$line/$1" ] && ! [ -x "$line/$1" ]; then
        echo "$1 is in \$PATH but is NOT executable"
        echo "Location: $line"
        exit 0
    fi
done < path-dirs

#tells user program is ready to use
while read -r line; do
    if [ -x "$line/$1" ]; then
        echo "$line/$1 is in \$PATH and is executable"
        echo "Location: $line"
        exit 0
    fi
done < path-dirs

#clean up
rm path-dirs

#program does is not in path
echo "$1 does not exist in \$PATH"
 
This is a good script for beginner c/c++ programmers. If you put your c executables inside of your home folder, you'd be just fine making this an alias:

Code:
#for compiling/testing/degbugging code in c with one command

gcc $1; a.out

I like the fact that gcc has the "a.out" convention, because it allows to test your code quickly before naming it.
 
Jas was saying at #51

Generally speaking locate is much faster than find. But it depends on a database that has to be regularly rebuilt (which takes some time to build). So the only downside of locate is that the accuracy of its results depends on how recently updatedb was last ran.

updatedb is a script that searches the entire file system and completely rebuilds the database used by locate. So if the database hasn’t been updated for a while - you may see results for files that have already been deleted. And won’t see results for any newer files that have been added since the last run of the script.

Most distros set up a cron job to periodically run updatedb in the background. So it is usually fairly accurate. But some distros may rely on the user to periodically run updatedb!

Or you might regularly shut your pc down before updatedb has even been ran! So the database could still be way out of date!

I use something which gets around that, and my database is updated whenever I use it.

BTW I find

Code:
sudo updatedb

to be very quick, but we work under different environments and I would be the last person to disagree with Jas :)

Today I ran this from one of my stable, MX-21, and be kind, because I still have to work on a carriage return for the first result.

For those unfamiliar with locate it typically comes under a package named mlocate (but could be plocate), which on a Debian based Distro you can install with

Code:
sudo apt -y install mlocate

You then have to update the database before first use, or else reboot (it loads and updates at boot).

So we've done that and now down to demonstrating its usage.

My script is called

locateme

and it is interactive. Its content is as follows

Code:
#!/bin/bash

# Asks for input then updates database and locates package/s
# even if just added

echo "Enter the package name: "

read  my_var1

read -s -p "Enter your password: " my_var2

sudo updatedb

locate $my_var1

I have chmodded it to +x to make it executable and it is stored in /usr/local/bin , which is in my Path.

The package or file I am going to look for is called

peekaboo

and I have used

Code:
touch peekaboo

to create it and then also seeded my home's

Documents
Downloads
Music
Public
Templates and
Videos

with it.

So being a dufus I have forgotten where I put it/downloaded it to and I use locateme to find it.

When it prompts me, I enter the package name/file name and when it prompts me again, I enter my password which remains invisible.

Code:
chris@MX21RC-SSD:~
$ locateme
Enter the package name:
peekaboo
Enter your password: /home/chris/Documents/peekaboo
/home/chris/Downloads/peekaboo
/home/chris/Music/peekaboo
/home/chris/Public/peekaboo
/home/chris/Templates/peekaboo
/home/chris/Videos/peekaboo

Works a treat.

A practical example?

I want to find all presences of Timeshift so I invoke locateme enter timeshift and my password, and get back the following

chris@MX21RC-SSD:~
$ locateme
Enter the package name
timeshift
Enter your password/etc/timeshift
/etc/timeshift/default.json
/etc/timeshift/timeshift.json
/usr/bin/timeshift
/usr/bin/timeshift-gtk
/usr/bin/timeshift-launcher
/usr/lib/debug/.dwz/x86_64-linux-gnu/timeshift.debug
/usr/share/timeshift
/usr/share/applications/timeshift-gtk.desktop
/usr/share/doc/timeshift
/usr/share/doc/timeshift/changelog.Debian.gz
/usr/share/doc/timeshift/copyright
/usr/share/icons/Papirus/16x16/apps/timeshift.svg
/usr/share/icons/Papirus/22x22/apps/timeshift.svg
/usr/share/icons/Papirus/24x24/apps/timeshift.svg
/usr/share/icons/Papirus/32x32/apps/timeshift.svg
/usr/share/icons/Papirus/48x48/apps/timeshift.svg
/usr/share/icons/Papirus/64x64/apps/timeshift.svg
/usr/share/icons/hicolor/128x128/apps/timeshift.png
/usr/share/icons/hicolor/16x16/apps/timeshift.png
/usr/share/icons/hicolor/22x22/apps/timeshift.png
/usr/share/icons/hicolor/24x24/apps/timeshift.png
/usr/share/icons/hicolor/32x32/apps/timeshift.png
/usr/share/icons/hicolor/48x48/apps/timeshift.png
/usr/share/icons/hicolor/64x64/apps/timeshift.png
/usr/share/icons/hicolor/96x96/apps/timeshift.png
/usr/share/locale/am/LC_MESSAGES/timeshift.mo
/usr/share/locale/ar/LC_MESSAGES/timeshift.mo
/usr/share/locale/az/LC_MESSAGES/timeshift.mo
/usr/share/locale/bg/LC_MESSAGES/timeshift.mo
/usr/share/locale/ca/LC_MESSAGES/timeshift.mo
/usr/share/locale/cs/LC_MESSAGES/timeshift.mo
/usr/share/locale/da/LC_MESSAGES/timeshift.mo
/usr/share/locale/de/LC_MESSAGES/timeshift.mo
/usr/share/locale/el/LC_MESSAGES/timeshift.mo
/usr/share/locale/en_GB/LC_MESSAGES/timeshift.mo
/usr/share/locale/es/LC_MESSAGES/timeshift.mo
/usr/share/locale/et/LC_MESSAGES/timeshift.mo
/usr/share/locale/eu/LC_MESSAGES/timeshift.mo
/usr/share/locale/fi/LC_MESSAGES/timeshift.mo
/usr/share/locale/fr/LC_MESSAGES/timeshift.mo
/usr/share/locale/he/LC_MESSAGES/timeshift.mo
/usr/share/locale/hi/LC_MESSAGES/timeshift.mo
/usr/share/locale/hr/LC_MESSAGES/timeshift.mo
/usr/share/locale/hu/LC_MESSAGES/timeshift.mo
/usr/share/locale/ia/LC_MESSAGES/timeshift.mo
/usr/share/locale/id/LC_MESSAGES/timeshift.mo
/usr/share/locale/is/LC_MESSAGES/timeshift.mo
/usr/share/locale/it/LC_MESSAGES/timeshift.mo
/usr/share/locale/ja/LC_MESSAGES/timeshift.mo
/usr/share/locale/ko/LC_MESSAGES/timeshift.mo
/usr/share/locale/lt/LC_MESSAGES/timeshift.mo
/usr/share/locale/nb/LC_MESSAGES/timeshift.mo
/usr/share/locale/ne/LC_MESSAGES/timeshift.mo
/usr/share/locale/nl/LC_MESSAGES/timeshift.mo
/usr/share/locale/pl/LC_MESSAGES/timeshift.mo
/usr/share/locale/pt/LC_MESSAGES/timeshift.mo
/usr/share/locale/pt_BR/LC_MESSAGES/timeshift.mo
/usr/share/locale/ro/LC_MESSAGES/timeshift.mo
/usr/share/locale/ru/LC_MESSAGES/timeshift.mo
/usr/share/locale/sk/LC_MESSAGES/timeshift.mo
/usr/share/locale/sr/LC_MESSAGES/timeshift.mo
/usr/share/locale/sv/LC_MESSAGES/timeshift.mo
/usr/share/locale/tr/LC_MESSAGES/timeshift.mo
/usr/share/locale/uk/LC_MESSAGES/timeshift.mo
/usr/share/locale/vi/LC_MESSAGES/timeshift.mo
/usr/share/locale/zh_CN/LC_MESSAGES/timeshift.mo
/usr/share/locale/zh_TW/LC_MESSAGES/timeshift.mo
/usr/share/man/man1/timeshift-gtk.1.gz
/usr/share/man/man1/timeshift-launcher.1.gz
/usr/share/man/man1/timeshift.1.gz
/usr/share/metainfo/timeshift.appdata.xml
/usr/share/pixmaps/timeshift.png
/usr/share/polkit-1/actions/in.teejeetech.pkexec.timeshift.policy
/usr/share/timeshift/images
/usr/share/timeshift/images/clock.png
/usr/share/timeshift/images/disk.png
/usr/share/timeshift/images/document-open-recent-symbolic.svg
/usr/share/timeshift/images/document-save-symbolic.svg
/usr/share/timeshift/images/donate.png
/usr/share/timeshift/images/drive-harddisk.svg
/usr/share/timeshift/images/edit-delete-symbolic.svg
/usr/share/timeshift/images/edit-delete.png
/usr/share/timeshift/images/emblem-default-symbolic.svg
/usr/share/timeshift/images/exclude.png
/usr/share/timeshift/images/folder-symbolic.svg
/usr/share/timeshift/images/gtk-file.png
/usr/share/timeshift/images/include.png
/usr/share/timeshift/images/item-blue.png
/usr/share/timeshift/images/item-gray.png
/usr/share/timeshift/images/item-green.png
/usr/share/timeshift/images/item-red.png
/usr/share/timeshift/images/item-yellow.png
/usr/share/timeshift/images/list-add.png
/usr/share/timeshift/images/list-remove.png
/usr/share/timeshift/images/locked.png
/usr/share/timeshift/images/media-optical.png
/usr/share/timeshift/images/open-menu-symbolic.svg
/usr/share/timeshift/images/preferences-system-symbolic.svg
/usr/share/timeshift/images/timeshift-shield-high.svg
/usr/share/timeshift/images/timeshift-shield-low.svg
/usr/share/timeshift/images/timeshift-shield-med.svg
/usr/share/timeshift/images/unlocked.png
/var/lib/dpkg/info/timeshift.conffiles
/var/lib/dpkg/info/timeshift.list
/var/lib/dpkg/info/timeshift.md5sums
/var/log/timeshift
/var/log/timeshift/2022-06-22_15-49-06_gui.log
/var/log/timeshift/2022-06-22_15-58-08_gui.log
/var/log/timeshift/2022-08-08_07-23-51_gui.log
/var/log/timeshift/2022-09-14_14-44-40_gui.log
/var/log/timeshift/2022-09-15_09-08-57_gui.log
/var/log/timeshift/2022-10-22_16-51-51_gui.log
/var/log/timeshift/2022-12-06_07-15-24_gui.log
/var/log/timeshift/2023-01-05_14-06-23_gui.log
/var/log/timeshift/2023-01-06_08-41-07_gui.log

Cheers

Wizard
 
I'm going through the very slow process of learning C because there just isn't any other way, i tried to really get at the heart of it through asking people online about and I was just dissapointed in the lack of willingness for people outside of this site to answer questions directly...their process was to just to basically just keep trying to give me advice about how i should be thinking about it...not interesting, seemingly kinda patronizing. I prefer talking to people who don't see my thought processes as being invalid/wrong.

anyways, the C for dummies book currently has a working URL for getting help with the answers, and in spirit with the book i made a script called wtf.sh:

Code:
#!/bin/bash

firefox https://www.c-for-dummies.com/begc4d/exercises/ &> /dev/null &

Link still works.
 
I'm going through the very slow process of learning C because there just isn't any other way, i tried to really get at the heart of it through asking people online about and I was just dissapointed in the lack of willingness for people outside of this site to answer questions directly...their process was to just to basically just keep trying to give me advice about how i should be thinking about it...not interesting, seemingly kinda patronizing. I prefer talking to people who don't see my thought processes as being invalid/wrong.

anyways, the C for dummies book currently has a working URL for getting help with the answers, and in spirit with the book i made a script called wtf.sh:

Code:
#!/bin/bash

firefox https://www.c-for-dummies.com/begc4d/exercises/ &> /dev/null &

Link still works.
Actually, no. The link should fail. You WANT it to fail because the certificate does not match the link.

-> Here is the correct link that passes the certificate check:
https://c-for-dummies.com/begc4d/exercises/

Here is the revised code from above:
Code:
#!/bin/bash

firefox https://c-for-dummies.com/begc4d/exercises/ &> /dev/null &

P.S. About Certificate Warnings: DO NOT IGNORE THEM!
Those certificate warnings are there to protect you. Ignore them at your own risk. I hope nobody here authorized "Accept the Risk and Continue" to see the web page without understanding WHY the error message appeared and determining that the webpage is safe.

-> If you do not understand the reason for a certificate error in your browser or you are not absolutely certain that the page is safe, do not approve an override and "Accept the Risk". You have been warned!
 
Last edited:
Actually, no. The link should fail. You WANT it to fail because the certificate does not match the link.

-> Here is the correct link that passes the certificate check:
https://c-for-dummies.com/begc4d/exercises/

Here is the revised code from above:
Code:
#!/bin/bash

firefox https://c-for-dummies.com/begc4d/exercises/ &> /dev/null &

P.S. About Certificate Warnings: DO NOT IGNORE THEM!
Those certificate warnings are there to protect you. Ignore them at your own risk. I hope nobody here authorized "Accept the Risk and Continue" to see the web page without understanding WHY the error message appeared and determining that the webpage is safe.

-> If you do not understand the reason for a certificate error in your browser or you are not absolutely certain that the page is safe, do not approve an override and "Accept the Risk". You have been warned!
"Fail" does not mean "i got a warning", it means "does not work". The script works just fine but yes you do get a warning which you can ignore because there's no risk that anyone will take password.

I would hope with anything security related one would not just believe whatever someone tells them, that's a real threat to security, not understanding that your browser could be over-reacting.

Certificates matter if you are submitting personal information to a website, otherwise they do not.
 
Last edited by a moderator:
"Fail" does not mean "i got a warning", it means "does not work". The script works just find but yes you do get a warning which you can ignore because there's no risk that anyone will take password.

I would hope with anything security related one would not just believe whatever someone tells them, that's a real threat to security, not understanding that your browser could be over-reacting.

Certificates matter if you are submitting personal information to a website, otherwise they do not.
In my opinion, it is poor advice to tell someone that a certificate warning is safe to "ignore because there's no risk that anyone will take password."

For starters, "take password" is not the only threat. Certificates matter even if you are not submitting personal information to a website.

My advice to others is never post a link in a public forum if it fails a certificate check. Do not tell people that it is safe to ignore certificate check failures. It is not always safe, even if you are not submitting personal information.

(True, there are reasonable exceptions. You may be teaching a course on information security, for example. The bad links in this thread are not one of those reasonable exceptions.)
 
Let's aim for keeping this thread on topic, thanks!

We've been doing pretty good at keeping it on topic! Well, good for us.
 
It's funny how i've been getting criticized for my recent script because firefox throws unclear error warnings about security when you run it, even though the code just runs fine, you have to realize that in the end firefox doesn't really know jack about security and human specific triage...

but my earlier script where I'm attempting to compare files for a cleaner looking output than "diff" or "comm" has huge amounts of bugs and nobody has said anything...

The prototypes for the script that don't don't have all the statements which test regular expressions worked okay, but if you see any of this kind of stuff, the script just doesn't work:

Code:
if [[ $2 =~ ^[-ucs] ]].....

The major challenge of coding is that sometimes something will look like it works properly, and portability is a straight-up nightmare from the coder's standpoint a good percentage of the time. I would hope that people get better at explaining both how to code properly and why open source is practically always more secure in comparison to proprietary, but I'm pessimistic about pretty much everything people do on a large scale.
 
Let's move on and remain on-topic. This is one of those 'on topic' threads. The topic is helpful shell scripts.

Thanks. Y'all can yell about it in PMs if you want. This is one of those 'on topic' threads.
 
I've finally made the best version of my comparison scripts, this whole process of wanting something i like better than diff has taught me two important things:

-that you basically have to have safeguards against every important user error when making interactive scripts, while leaving open the possibility for the user to mess up in ways that don't have anything to do with the internal logic of the script. For example, if you only ask for input after you've executed the program, then an unnecessary argument doesn't matter. However, if you have a script that accepts arguments, you have to ensure that all the arguments are screened before they are used by the script.

-Unfortunately, computer languages are normally not designed to be compatible with everyone's imagination, it's important to quickly accept something isn't working and you can't do everything sooner rather than later :)

Below is the script. It is designed to allow you to change the name of the script while keeping error message clarity, feed two text files to it as arguments, and tell you when you get forgetful of how to use it. It still might not warn you against ALL the wrong types of arguments, but the error messages in programs normally aren't perfect. You'll notice that half of the file is used to tell the user if they've messed up and how:

Code:
#!/bin/bash
#easier to read format for showing differences between files

#makes script name a variable for error messages
SCRIPT=$0

#error gauntlet, test number of arguments
if [ $# -lt 2 ] || [ $# -ge 3 ]; then
        echo "This script needs two or three arguments: ${SCRIPT##*/} file file2"
        exit 1
fi

#test if files exist
if ! [ -f $1 ] && ! [ -f $2 ]; then
        echo "$1 and $2 do not exist as regular files."
        exit 1
elif ! [ -f $1 ]; then
        echo "$1 does not exist as a regular file."
        exit 1
elif ! [ -f $2 ]; then
        echo "$2 does not exist as a regular file."
        exit 1
else
        :
fi

#removes leading spaces to make output more useful
sed 's/^[ \t]*//g' $1 > temp-diff

sed 's/^[ \t]*//g' $2 > temp-diff2

#uses diff and sort to accurately tell you what's different about each file, THEN removes blank lines
#to make output more useful
echo -e "These lines are unique to $1:\n"

diff --new-line-format="" --unchanged-line-format="" <(sort temp-diff) <(sort temp-diff2) | sed '/^$/d'

echo -e "\nThese lines are unique to $2:\n"

diff --new-line-format="" --unchanged-line-format="" <(sort temp-diff2) <(sort temp-diff) | sed '/^$/d'

#removes temporary files when done using them
rm temp-diff temp-diff2

And of course, i found more issues with it after putting it up, but just with the error messages this time! Now it does exactly what i intended, hopefully.
 
Last edited by a moderator:

Members online


Top