r/UnixProTips • • Feb 26 '15

Quick set operations

5 Upvotes

If you have two lists of strings (for example, file names) and you want to get strings that are present in the first list, but not in the second, a quick way to do it is:

cat list1 list2 list2 | sort | uniq -u

Other set operations are possible by duplicating another list contents and/or using uniq -d.

Of course, it is more correct and efficient to use comm(1), but the suggested way doesn't require lists to be pre-sorted and allows processing of pipeline and command outputs without need of intermediate files.


r/UnixProTips • • Feb 07 '15

Add a default opening command to bashrc

5 Upvotes

In my bashrc I have :

alias gop='gnome-open'

This allows me to do

gop <file_name>

And it will open with the default program... Perhaps there's a nicer way of doing this, I'm all ears :)


r/UnixProTips • • Feb 04 '15

pss, a simple bash function to grep the ps output (colored output)

5 Upvotes

A simple function to quickly grep the output of ps (green colored)

pss() {
    if [ "$1" == "" ]; then
        echo -e "usage: pss NAME\n"
    else
        echo -e "\033[1;32m`ps ax | grep $1 | grep -v grep`\033[0m"
    fi
}

r/UnixProTips • • Feb 03 '15

handy hddtemp bash function

5 Upvotes

Once in a while i want to check the temperature of the hdd's which i have installed in my system, so i thought i create a handy bash function for that. :)

hdtemp() {
    i=0
    hdd_dev_list=(
        '/dev/sdc'
        '/dev/sdb'
    )

    for i in ${hdd_dev_list[@]}; do
        echo -e "$i `sudo hddtemp $i | awk {'print $3'}`"
    done
}

r/UnixProTips • • Feb 03 '15

Collaboration?

5 Upvotes

Have you considered working with https://twitter.com/climagic ?


r/UnixProTips • • Jan 27 '24

Install FreeBSD 14.0 in QEMU VM with KDE Plasma tutorial kdesrc-build Qt6

Thumbnail
youtube.com
4 Upvotes

r/UnixProTips • • Feb 06 '15

Need to post code on reddit? You want to prepend 4 spaces?

4 Upvotes

I know RES will do this for you, but if you don't use it and want it for yourself here you go.

sed 's/^/ /' file | xclip -sel c

Note the second part of that sed is four spaces, and you can use whatever clipboard you ave installed.


r/UnixProTips • • Feb 05 '15

Change Title of Terminal Programs

4 Upvotes

Works on at least some X terminals.

function title () {
    [[ "${TERM}" != 'linux' ]] && printf "\033]0;%s\007\n" "$@"
}

Should work in bash, zsh, etc.


r/UnixProTips • • Oct 18 '19

Best shell prompt

3 Upvotes

What is your preferred *nix shell prompt (i.e.$PROMPT, $PS1, etc.) and why?

Plain “%” or “#? Or do you use something so complex that it takes up most of the line?


r/UnixProTips • • Dec 18 '17

Any suggestions on how to utilize ITEOC for text alerts?

3 Upvotes

r/UnixProTips • • Feb 05 '15

Use autocd

3 Upvotes

With autocd active, you can "execute" folders by name to do a cd. For example:

L ~/tmp % ..
L ~ % tmp
L ~/tmp % 

I learned to like this after years of using JPSoft's 4DOS and 4NT. I don't know how much time this actually saves me, but it certainly feels like a lot, and that's good enough for me.

To do this in bash:

shopt -s autocd

In zsh:

setopt autocd

Probably best not to do this for root - since if there is an executable on PATH that shares its name with a folder in the current folder, that executable will be run instead. This has yet to cause me any problems, and besides there are few Unix utilities that do anything serious when invoked without options - but best to be safe.


r/UnixProTips • • Feb 05 '15

Shift-ctrl-u for Unicode entry.

3 Upvotes

I think this only works in Linux (and not in the console) but it's brilliant. Try it out now in the comment field. When you're entering text, just hit shift-ctrl-u, and you will see an underlined 'u'. Then you enter the hex code for any Unicode character and it will appear.


r/UnixProTips • • May 04 '26

please help (warning loud noise) Spoiler

2 Upvotes

r/UnixProTips • • Dec 15 '21

AM, the Application Manager that supports multiple architectures

Thumbnail self.appimage
2 Upvotes

r/UnixProTips • • Aug 02 '19

Help training newbies

2 Upvotes

Please let me know if wrong please Reddit here,

Some help needed pls from Unix experts who have successfully trained others. Note I am far from a Unix expert myself.

Some context…. I work in a large UK Local government supporting a very core important system where the ICT Infrastructure/server (and its maintenance and DBA, is handled by a centralised ICT department/, who are often unable or unwilling to make changes to the server, as the supplier is quite specific).

The supplier also supports red hat as an alternative host OS to Solaris but....that's a bigger discussion, beyond my pay grade...

Anyway, we are way behind the curve, still using Solaris 11 and our Unix scripts are all #ksh. My team are by no means Unix experts (we have a few Unix managers within the ICT looking after the whole estate) but in my area...,we do just what we do… Log into putty/SSH, invoke Ingres's isql CLI command, write SQL, Create reports for managers here, and try and automate as much of this as possible by asking ICT to run the reports (shell scripts) as and when we can (system has a batch scheduler front end)

However, in my smaller team (outside of ICT, different building) we have (almost) full terminal server access in order to perform frequent day to day database changes using Ingres isql command, and fault resolution and help desk function for a particular Ingres based system (on Solaris) and the vast majority of this require back end access to said database.

We've asked many times for some kind of windows front end this backend Ingres database which would minimise risk around using the terminal, but never had a reply from ICT.

This is deemed to be a security risk by our internal auditors, however, we have managed to convince them otherwise due to the nature of the poor software which means that we often have to go in and change things our selves, and the supplier is reluctant to enhance it.

Anyway….

I now have to train up two people from scratch on this in two days. One knows the database layout but does not know how to write a shell script, so cannot truly exploit the automation scripting functionality therein.

The second guy, however, has a real keenness to learn and will pick up shell programming much easier as he has experience with other programming languages.

I am not a natural-born trainer and would be the first to tell them this. When they look at my scripts they don't understand them

I'm at a bit of a loss as to what to do here.

I wish I could clone a more patient version of me

Does anyone have any advice?

I can extend the training if needs be but it will be sporadic days here and there

I'm also very aware that over the years I have developed my own ways of doing singers which may not be the most efficient way of doing them…., . maybe more recent and better Unix commands exist to achieve the same things… But I have avoided these because of their perceived complexity eg awk ( I have avoided this like the plague because I never found the time to really understand it, but I'd like three trainees to hopefully understand it better than me and develop cleaner and more efficient solutions.

Any thoughts?


r/UnixProTips • • Apr 02 '17

Spotify text formatting help

2 Upvotes

Has anyone come across a fix for changing the text size in Spotify? On high DPI screens the text is barely readable


r/UnixProTips • • Jul 23 '16

Google translate through the shell doesn't work

2 Upvotes

The google translate function written in this post doesn't seem to work for me. I just get a blank output in my case.

$ gt fr Donaudampfschiffkapitän

$ gt Donaudampfschiffkapitän

$ vi .bashrc

I'm using Ubuntu 16.04 64bit, with Firefox 47 (for which Mozilla/5.0 should work)


r/UnixProTips • • Feb 18 '15

Sidebar additions request [tools]

2 Upvotes

Would it be ok to add /r/awk and /r/sed to the sidebar? I didn't create them; I just think they're related/similar enough to link. :-)


r/UnixProTips • • Feb 07 '15

Finished my battery low warning script. Learned about limitations of cron and the difference between lexical and numeric comparisons.

Thumbnail paste.debian.net
0 Upvotes

r/UnixProTips • • Oct 04 '26

Dam

Post image
0 Upvotes

Does anyone know if such rice exists for linux?