Hmm, maybe some weird default. Every user has their own shell assigned. If not, it uses the system’s default shell.
I’ve just written the following quick script for you to check the default shell for any user by querying /etc/passwd.
#!/bin/bash
#########################################################################
# Copyright (C) 2022 Akito <the@akito.ooo> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
#########################################################################
user="$1"
[[ -z "$user" ]] && \
echo "You must provide a user as the first argument to this script!" && \
exit 1
passwd="$(</etc/passwd)"
passwd_entry_user="$(grep "$1" <<<"${passwd}")"
[[ $? != 0 ]] && \
echo "Provided user does not exist!" && \
exit 1
printf '%s\n' "${passwd_entry_user##*:}"
I tried it out and it works superbly. Now I wanted to get it going in the fish shell, too.
Here it works thus: sed "/^ *\$/d" txt
In this case the backslash before the dollar-sign is needed.
Thank you very much for providing some awk examples.
rmnull.awk I understand. It works splendidly as well.
Alas sum.awk and cut.awk already seem to be beyond my grasp.
Sorry, Neville.
That I believe.
One thing I noticed when running awk -f rmnull.awk txt: The awk-script runs successfully with standard permissions: -rw-r--r-- 1 rosika2 rosika2 28 Apr 6 14:59 rmnull.awk
Is there no need to make it executable like bash-scripts
Many thanks again for providing some introductory examples, Neville.
No, no need. It is just a file read by awk. It is awk itself that is executing.
If you want to go further with awk find a tutorial on the web
Those $1,$2, etc are first field, second field, etc on each line
Awk divides each line into fields
For a text file fields are words, so that first script works by checking if there is a word on the line.
For a data file, a field is a data item separated by blanks or tab. The second and third scripts are for data files.
If you needed to backslash the $ in fish it suggests the " " are not protecting the sed command from the shell.
So in fish single quote is more powerful than double quote in protecting strings from the shell
but
in bash double quote is more powerful than single quote.
Sure Rosika,
If you have some part of a command not quoted, the shell will act on any regex characters in it, before it is passed on to sed or awk or whatever.
So a * for example will be replaced by a list of all the filenames in the directory , and then that list will be passed on.
To stop the shell getting in first , when there are regex characters in the command, you quote it. The quotes protect it from being interpreted as a regular expression by the shell.
Unfortunately various shells react differently to the two types of quotes.
I am sorry that is complicated.
It is all because the shell gets to see what is on each line, before any commands on the line get to see it. So the shell can get in first and modify it. You may not want that so you use quotes. The shell is not supposed to look inside the pair of quotes. That is what I mean by protecting.
This is one of the worst issues with shellscripts. Master this and you are an expert.
Yes, I think the documentation is quite extensive.
Plus: With the installation of fish you get the whole documentation-bundle installed locally.
Just type “help” into your terminal and your browser automatically opens up the page
That brings back memories.
With FreeBSD all the Unix documents came with the installation. That is where those sh and csh documents came from, from archives of FreeBSD files.
Linux does not seem to have acquired that feature. It relies on web documents. Julia is even more extreme - its libraries of packages dont even install… all packages and docs are on github.
Sounds interesting. Is this still the case today?
And is it also true for other BSD distros (e.g. OpenBSD)?
I´m asking because I´d like to try a version of BSD in a VM one fine day.
Well, I hadn´t heard of julia before. So I looked it up…
env LANG=en_US.UTF-8 apt-cache show julia
[...]
Julia is a high-level, high-performance dynamic programming language for
technical computing, with syntax that is familiar to users of other technical
computing environments.
[...]
Can not answer that. 15 years since I used BSD.
Will do some research. I have a live FreeBSD DVD. Will look there.
You used to be able to download the entire sourcecode of FreeBSD, and have it appear in the src directory. That is what src used to be for. You could compile it from there and make a new kernel.
I do know , most of the BSD’s use only ZFS filesystem. That is a barrier for me today. All my files are on ext4 partitions. I could not access my files.
A compromise is Void. It is a BSD / Linux hybrid. It can read ext4.
Oh, now I feel really bad.
I certainly didn´t want to give you any trouble in doing more work on my behalf than you already have.
Perhaps I can do some research on that…
Thanks also for the additional info about the ZFS filesystem.
[…] the 4.4BSD Lite Documents which are part of the FreeBSD operating system
It really seems the docs are part of the os. Well, that´s really great.
As I mentioned earlier: for people with limited data download (and upload) that should be a treat.
Thanks again for your investigating the matter.
Many greetings and have a nice weekend.
Rosika