There is a more straightforward way to do this, plus a more arcane way (syntax-wise). There's a lot of arcane in the Bash Shell and in some ways, it's like Vim: you just have to get used to things, try and remember them and not ask "why?" too much.
If you have a file path and want to know the last part (usually the file name) only, you can use the command basename (man basename) e.g. If I have a path : /usr/include/stdio.h, then :
Gives me : stdio.h.
The command also has options to strip a suffix (e.g. the ".h" part).
Alternatively, a more arcane was is to use the parameter expansion functionality of the Bash shell.
This is looking for a pattern ("##") and stripping everything up to the last "/" (*/). It gives us the following output :
Did I mention arcane? There are are lot of very useful features like this in the Bash shell but they can just be a little hard to remember sometimes (and you have to watch out for "gotchas" using them!).
See Bash Manual : Parameter Expansion
In vim you can be in a visual selection mode, perhaps selecting only parts of the text file. Normally, a substitution operation (e.g. replace string "2022" with "2023") operates on a whole line (or range of lines). To restrict this to operate only on the visual selection you have, use the "\%V" pattern at the start of your search.
So, assuming a visual selection is highlighted and within this I want to change "-" to " " :
A highlight containing "This-is-a-test" becomes "This is a test".
See Vim help %V
My server has USB 2.0 only and I thought I'd upgrade it to USB 3.0 via a Startech USB 3.0 PCI card. Installation was straightforward but after restarting the computer I discovered my networking was broken.
It turns out that my ethernet device used to be enp2s0 but was now enp3s0 and my network setup failed.
This type of kernel device name is created based on various schemes e.g. the physical location of the connector of the hardware on the PCI bus. See the Redhat Docs.
I've been using Linux for many years now and computers have changed a lot in this time. Leaving aside the huge advances in CPU, RAM and storage, many computer devices are not "fixed" in place but can come and go (even CPU's and RAM). Mostly, these devices might get plugged in or out, such as a USB mouse or external USB hard drive. PCI devices are also capable of being "hotplugged" and when any of this happens, the kernel has to scan the new configuration and determine what devices are present. Sometimes it has to re-arrange the device names.
My server is an old HP Microserver (N36L) : 12 years old now but still going strong (although it needed a new power supply last year). Because I use an external USB disk for backup, USB 3.0 will speed things up a lot (I hope). On to the reboot and networking failure ...
To fix this, I could just change my ethernet device name in my network setup files (i.e. /etc/network/interfaces on Debian). I decided to use systemd and create my own persistent and simple (old-fashioned) name for the device.
This is "link" as in a network link (man page : systemd.link).
to get the MAC address for the network device enp3s0. Then create the file :
The file must end with ".link" and preferably begin with numbers (as a run order). It contains :
[Match] MACAddress=<YOUR MAC ADDRESS> [Link] Name=eth0
I edited my network setup scripts (Debian : /etc/network/interfaces) to use the network name "eth0". Now, when I boot the system, the name "eth0" is set on the network device with my main ethernet MAC address and will stay that way.
I must add that I like systemd and how it's changed the Linux boot and system control landscape.
In January last year, I posted a piece about a small study I had done of Arthur's Seat called The Seat by the Loch. I worried that the picture was a bit too saccharine. Maybe it was, but I decided I ignore any qualms and go all in on the "colour" : and so painted a larger version. This was done in July 2022 and I think it turned out okay. So, varnished, framed and hanging on a wall somewhere near me :
This is a view of St Margaret's Loch and St Anthony's Chapel on Arthur's Seat, Edinburgh. I'd sometimes have lunch sitting up there with friends, and sharing the rocks opposite the chapel with some ravens chasing any crumbs falling their way. Better a raven than a gull.
What I learnt Lately no. 2 : How to change the colour Vim uses for its tabs.
The editor Vim has "tabs" similar to tabs in other applications (text editors, browsers), or at least can be made similar. I use a plugin called buftabline for my Vim tabs. Vim buffers are shown as classic-style tabs along the top of the window.
One thing I didn't like was the fact that the empty space on this tab bar was shown as white :
To change this, use the "highlight" command and apply different colours to the tab elements :
That's much better and a lot clearer to see what buffer/tab I'm looking at with a glance.
This is what I have in my .vimrc settings file :
highlight TabLineFill term=bold cterm=bold ctermbg=0 highlight TabLineSel ctermfg=0 ctermbg=LightYellow
Note that the vim plugin buftabline has its own set of colour (highlight) groups e.g. BufTabLineActive (these are linked to the built-in tab groups). See the github page.
This page was very useful :
I love tinkering around with the computer and digging into some of the aspects of running Linux, or the more interesting applications it can host. Take the editor Vim. Not a text editor for the masses (to say the least) but it does have an extremely broad and deep set of features and also a whole swathe of settings for them. I've not done much painting recently and have spent some time sorting out my computing experience. For this, I've learnt quite a few new things and it's made me remember how pleasurable learning stuff is.
So : What I have learnt lately a.k.a. WILL. Maybe I will try and document some of these things, if only for my own reference later.
Viewing some old server backup logs (something else I've been "fixing"), I wanted to jump to the next line not starting with a word ("deleting").
I use the Vim text editor. To find a line that starts with a string, use the "^" regex anchor. Press "/" and :
The "<cr>" means press the return/enter key. So "^deleting" matches the word deleting at the start of a line.
The "/v" means interpret the pattern used as "very magic", so no need to quote brackets etc. See vimdoc for an explanation.
Now for the good stuff (and new to me) : to find a line not starting with "deleting", press "/" and :
This is similar to before but we wrap the pattern in brackets and end with "@!". The "@!" is a negative lookaround (i.e. "lookbehind") i.e. looks for no matching pattern behind us. The "^" means "at start of line" (behind us).
To help retain a piece of knowledge, it's usually useful to write it down somewhere.
The Book of the New Sun
by Gene Wolf
The Book of the New Sun by Gene Wolf is composed of four "books" that I have in two volumes. It is set on a far future Earth, with the sun dying but human kind still around. Much has changed and much forgotten, almost all history is lost or barely remembered.
In brief, we follow a young man called Severian, an apprentice torturer (the guild otherwise known as "The Seekers for Truth and Penitence"). Expelled from his guild for showing mercy, he is exiled and has to go on a journey to a far city, armed with an impressive sword and picking up a mysterious gem stone by accident on the way. We meet some odd characters who he joins or join him, and he battles some more bizarre creatures. The gem stone has some strange power and over the course of his travels he learns part of the secret to the world and its governing powers.
A number of times over the last few years I have come across people saying how great this novel was and so I added it to my reading list. The time was finally right to jump in. Or so I thought.
Well, I seriously struggled to get through the books and almost gave up on multiple occasions: after the first book, then after the second. I think I decided that, like having a "sunk cost" here, I might as well push through it. It's not a bad book, and not badly written, but just quite baffling in many ways. I found the (far future Earth) world interesting but hardly revealed or explained. The same with the characters, whose motivations were obscure to me mostly. Always expecting the pace to pick up and something to happen, it mostly didn't and things plodded forward, often slowly. When things did happen, they often seemed to happen as merely a plot device: people would appear, go away and then meet later. Often a bit too much coincidence. As each book ended, I felt generally unrewarded. On to the next?
Like I say, I did read all of them and the books improved for me after the bumpy start. Maybe it was actually the wrong time for me to read the novels; maybe I was expecting something quite different. When I read many other positive reviews now I see much talk of the books needing to be read more than once, to get the nuance and pick up Wolf's cleverly constructed, but slightly obscured, meaning. However, I think a book should stand up to a first reading. Even if the novels contain a lot of not-so-obvious clues to the events and history of the place, Wolf might have been a bit too clever for me.
by James S. A. Corey
As written on the frontispiece of the last in the series :
Nine books later and you're still here, so this one's for you.
Nine books is very impressive. They're chunky as well, but the biggest deal is how consistently good they are. And nine books later I get to the end of The Expanse and close the final book, Leviathan Falls. I've waited a long time for the last book to appear: the paperback version seemed to take forever to get released.
This has been the best action/adventure series I have read, consistently good and usually great. The series started well and stayed that way: if anything, it got better. Quite a believable future mapped out by the two authors, Daniel Abraham and Ty Franck ("Corey" is a pen name), with the solar system politics and fighting looking a bit parochial as the story expanded into a huge galaxy spanning collection of worlds.
In the end though, what made these novels special were the characters, who we get to know, understand and love. With the vast distances involved, the characters age and by the final few books, they're decades older, and showing it. We've grown besides them.
It's always hard finishing a book you love reading and even if the end is somewhat bitter-sweet, Leviathan Falls does not disappoint.
Player of Games
by Iain M. Banks
Second time lucky? The last time I read Player of Games I was underwhelmed. I thought the book was okay but a little dull, perhaps a bit hard to understand and lacking in action. Over the years since, however, I keep on coming across people online who consider this book a favourite, and perhaps the best "Culture" novel he wrote. So, an impetus to give it another chance. As is increasingly clear to me, the reaction you have to a book is very dependent on when you read it.
So now I am very glad I came back to the novel because I really liked it this time. I'd forgotten almost all of the story so it felt fresh. It is not action packed, akthough it has some and is a bit more "cerebral" perhaps. The story's about a complicated game: a "game" a society uses as a part of its organising principles. So we learn about cruelty, hierarchy, equality and politics through a cast of very different, and not always very likeable, characters. This is typical Banks, as is the "Culture" culture and humour, including a malicious drone. Things are not always what they seem but we get a satisfying, dare I say, happy ending?
I think I would now consider myself a "booster" of this book.
Going through some of my old comics and comic books, I came across a hardback French edition of Moebius' Le Garage Hermétique, the first version in colour. A true classic of French bande dessiné and a strip I first came across in the American Heavy Metal magazine in the late 1970's. This colour version was published by Les Humanoïdes Associés in October 1988.
Inside is a colour poster insert: a blow-up of one of the most striking panels in the strip. I had completely forgotten about his but what a wonderful surprise to rediscover. It is revealed that it was a woman under that hat all along, not a man!
This is not something to leave hidden away inside a book anymore. It deserves a frame and to be hanging on a wall. RIP Jean Giraud a.k.a. Moebius.