date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,416,436,772,000
This is related to Shell script too slow for output to Conky This code is nearly perfect: stdbuf -oL jack_cpu_load \ | grep --line-buffered "jack DSP load" \ | stdbuf -oL cut -d' ' -f4 \ | while read line; do echo "scale=0; $line*100/1" | bc -l > /tmp/buffer done & The only issue is that bc re...
You just need to make it stdbuf -oL jack_cpu_load | grep --line-buffered "jack DSP load" | stdbuf -oL cut -d' ' -f4 | while read line; do echo "$line" > /tmp/buffer; done & to output the value that you input without modification.
bc removes decimal point
1,416,436,772,000
I am comparing the floating point values in shell script based on this reference. Following is the script contents num1=50.960 num2=6.65E+07 echo "${num1} < ${num2}" | bc When I ran the script the output is '0'. But according to the comparison it should be '1'. I need inputs on why the comparison is not working as ex...
The bc utility does not understand 6.65E+07 as the number you want it to be. On OpenBSD, the E here is hexadecimal, so 6.65E is 6.664 (6.65 + 0.014), and then +07 will add 7 to that, yielding 13.664, and that is clearly less than 50.960. On GNU systems, 6.65E is 6.659 which is also not what you want. Instead, you wan...
Floating point comparison in shell
1,416,436,772,000
I want to do simple coding by storing the output calculation in variable and display the result in decimal point using command bc. But it only works on for minus calculation not for division calculation. numberTotalX=$(echo "$varnameY - $var1" | bc) echo " Number.total.x is $numberTotalX " the result is: Number.tot...
You are looking for scale, just use: numberSplitInteger=$(echo "scale=x;$numberTotalX / $var2" | bc) It will give you x values after decimal.
How display the output of calculation in decimal point using bc command
1,416,436,772,000
I am trying to find square root of 12345 and then scale it to 100 decimal places using the command shown below: val=$(bc <<< "scale=100 ; sqrt ( 12345) " ) But the problem is I want to rescale the value to 10 decimal places using bc only in echo command but it is not working, I tried following code of lines but none ...
If you are not worried about rounding in bc, you can do: $ echo "scale=10 ; "$val/1" " | bc 111.1080555135 It is when a value gets divided (even by 1) that the number of decimals gets adjusted to the scale. Of course, you can always use the shell printf (again, some rounding might crawl in). $ printf '%5.10f\n' "$val...
Rescaling a scaled value using bc command
1,416,436,772,000
I'm trying to remove an integer from a decimal value that I currently have. current syntax: h=$(echo "scale=2; (($e/$g/$g))" | bc) echo $h The following is used to convert seconds to minutes and then hours however it returns "21.15" hours. I want to keep the 0.15 and multiply it by 60 (leaving me with 9 minutes)...
The bc remainder operator is % expr % expr The result of the expression is the "remainder" and it is com‐ puted in the following way. To compute a%b, first a/b is com‐ puted to scale digits. That result is used to compute a-(a/b)*b to the scale of the maximum of scale+...
Discard integer and keep floating point
1,612,895,013,000
I have a bind9 testing environment in Debian wheezy that I am trying to set up two A records that are returned in a fixed order. In my named.conf.options file I have the following configuration: options { ... rrset-order { order fixed; }; }; This is functional to the point that my records are always returned...
Bind9 on Wheezy doesn't allow for that option. Also one must ask himself why one wants/needs this as it breaks when it hits the cache of some recursor. Also for failover purposes it is not really suited as most clients don't have the code to make that happen. If you maintain the client code, then having a look into SR...
How to return multiple DNS A records in a specific order using bind9?
1,612,895,013,000
I have a BIND 9.9.5-9+deb8u8-Raspbian DNS server running on a RPi3 in my network. It is - for everything that's not my home-zone - configured as a "forward only" with the forwarders "{ 8.8.8.8; 8.8.4.4; 208.67.222.222; 208.67.220.220; };". a) the normal case Usually, dns resolution works perfectly. Even when results a...
After more research, the problem appears to be the following: The initial setup contained both forwarders that were DNSSEC-capable (GoogleDNS 8.8.8.8, 8.8.4.4) and some that weren't (OpenDNS 208.67.222.222, 208.67.220.220). I had BIND9 running with DNSSEC fully enabled, as per the following configuration: dnssec-enabl...
BIND9: DNS resolves sometimes (!) take very long or don't work at all
1,612,895,013,000
I'm configuring BIND9 to obtain a wildcard certificate from Let's Encrypt. When I try to generate TSIG key according to instruction here, I got the following error: # dnssec-keygen -a HMAC-SHA512 -b 512 -n HOST keyname. dnssec-keygen: fatal: unknown algorithm HMAC-SHA512 Then I read help and document about dnssec-key...
After a bit searching, I found the document of plugin certbot-dns-rfc2136 is obsolete! In BIND9's official git repository, I found the following commit message: [func] The use of dnssec-keygen to generate HMAC keys is deprecated in favor of tsig-keygen. dnssec-keygen will print a warning wh...
How to generate TSIG key for certbot plugin 'certbot-dns-rfc2136'
1,612,895,013,000
I was looking at bind9-host shirish@debian:"04 Jan 2020 15:48:02" ~$ aptitude show bind9-host=1:9.11.5.P4+dfsg-5.1+b1 Package: bind9-host Version: 1:9.11.5.P4+dfsg-5.1+b1 State: installed Automatically installed: no Priority: standard Section: net Maintainer: Debian DNS Team <[email protected]> ...
host is not deprecated by Internet Systems Consortium, the BIND company. It does not even deprecate nslookup as it once did. This deprecation of host was done in 2018 by a Debian Developer, on xyr own initiative, in response to a 2013 Debian bug report about the package description that did not actually mention depre...
why host from bind9-host is/was deprecated and when?
1,612,895,013,000
I'm running a name server using bind9 on Debian. I noticed that there are multiple "named" processes running, when bind starts: How can I limit this to n bind instances (processes)? What is the recommended use of multiple bind processes? I know that bind is a relatively low intensive application in terms of CPU and ...
Depending on your distro there's likely a configuration file that can contain the following switch to named, -n #cpus. from the named man page -n #cpus Create #cpus worker threads to take advantage of multiple CPUs. If not specified, named will try to determine the number of CPUs present a...
Multiple named processes for bind9 in Debian
1,612,895,013,000
Reading about acl statement in bind's ARM found the following: localnets: "Matches any host on an IPv4 or IPv6 network for which the system has an interface. When addresses are added or removed, the localnets ACL element is updated to reflect the changes." "for which the system has an interface" - sound like a nosense...
I guess localhost refer to one IP address which is by default 127.0.0.1, but, localnet refer to every network that you have an IP address from it on interface on your machine. For example, if you have two interfaces and every one have its IP from different network so localnets can match all networks. eth0 ip 10.0.0.1 ...
What is the difference between localhost and localnets in named configuration
1,612,895,013,000
I have a bind9 server spun up on one of my old test test boxes, and it's close. Everything appears to be working, however I'm getting 'time out resolving' errors spamming my sys.log from what appears to be 3 specific DNS servers... 68.237.161.12 68.237.161.14 156.154.71.1 bind9 info Jul 25 07:18:59 toe-lfs named[2393...
I just had this and fixed it by removing the faulty forwarders. At the end of each timeout error is an IP from a forwarder from your config, but the errors never complain about google's ns (8.8.8.8). If you delete the first three forwarders, the errors should go away.
bind9 - timed out resolving
1,612,895,013,000
Resolvconf is a package born to handle different specific situations like lans with dhcp, vpn, and other situation where everyone try to change manually the /etc/resolv.conf file. It has an algorithm where the max priority is obtained with a list of interfaces, as example tun and dhcp clients goes over a ppp connectio...
Fine seems after some tries i found a solution... By commenting all the localhost lines in interface-order file, expecially this two lines: # lo.@(dnsmasq|pdnsd) # lo.!(pdns|pdns-recursor) Everything worked as wanted ;)
Prevent resolvconf package assign localhost if named bind9/dnsmasq is found on host
1,612,895,013,000
I came across a strange problem. Maybe someone knows the answer. I use named-checkzone to check my zone file. The following zone file will display ignoring out-of-zone data when I use fully qualified domain names: $TTL 30 @ IN SOA localhost. admin.example.com. ( 2017072702 ; serial 3 ; refresh 1 ...
The command was wrong. Instead of the FQDN the first parameter has to be the zone: sudo named-checkzone example.com /var/named/example.com.zone
named-checkzone displays “ignoring out-of-zone” data
1,612,895,013,000
I tried to block the .zip TLD on my laptop (running fedora 38) with bind. Installing bind Updating named.conf: options { listen-on port 53 { 127.0.0.1; }; listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_s...
I think I solved it? If I’m not mistaken, the problem seems to be with systemd-resolve / resolvectl not persisting it’s settings for long... If I change the file /etc/systemd/resolved.conf such that it contains ... [Resolve] DNS=127.0.0.1 ... And then reboot, it seems to do (finally) what it should. I’d still like t...
How do I get BIND (DNS) to be authoritative about a tld for more than a minute
1,612,895,013,000
I set up a DNS server using the bind9 utility, took the settings from the example, and this is how the configuration turned out: file: /etc/bind/named.conf.local // // Do any local configuration here // // Consider adding the 1918 zones here, if they are not used in your // organization //include "/etc/bind/zones.rfc...
For Linux hosts you should put the following in their /etc/resolv.conf: nameserver 192.168.12.1 search testing.net They should then test with: ping demo Don't forget to put the following line in /etc/bind/db.forward.com: demo IN A 192.168.12.<host ip> and in /etc/bind/db.reverse.com: <host ip> IN ...
Add another name to DNS server bind9
1,612,895,013,000
I have a DNS server with Bind9 installed, that has IP 192.168.145.119. This works as a resolver for a DNS server on IP 192.168.145.1. I have setup so it works as a forwarder when using ping, using dig etc. I have also setup a zone with CNAME's. This works fine, as intended. However, reverse lookups doesn't work. If I ...
In one of the configurations I had a lot of empty zones. I had to add empty-zones-enable no; to my named.conf. Now it looks like this: include "/etc/bind/named.conf.local"; include "/etc/bind/named.conf.default-zones"; options { directory "/var/cache/bind"; recursion yes; allow-query { any; }; empty-zones...
Forward reverse lookups with Bind9
1,612,895,013,000
I am running a DNS and DCHP service on a local server (Raspberry on Stretch). When checking the zone files, I get: # [2019-02-03 10:32] maxg@rpiserver /etc/bind/zones $ named-checkzone rpiserver argylecourt.org.db argylecourt.org.db:22: ignoring out-of-zone data (argylecourt.org) argylecourt.org.db:23: ignoring out-o...
I started digging further when I realised the old serial number. I looked up cat /etc/bind/named.conf.local, which pointed to [file "/var/lib/bind/argylecourt.org.db";] ... while I was updating /etc/bind/zones/argylecourt.org.db
BIND9 DNS zone file check reveals "ignoring out-of-zone data"
1,612,895,013,000
I'd like to build bind zone files via Ansible. To decide how to structure the jinja2 template I need to know if there is any difference in any of these zone configurations: 1.) good old fashioned way: $ORIGIN foo.bar. @ IN SOA dns.foo.bar. hostmaster.foo.bar. ( 2018111601 ...
Answer: yes, they're all the same. Though note I haven't actually loaded these zones in to a DNS server to confirm; e.g., I may have missed a typo when reading the question. Load them in to a DNS server, allow zone transfers, and then transfer them — you should get the exact same result. Details: If you check “Other...
There is any difference between this zone syntax?
1,612,895,013,000
i use bind for simple setup on my lan, just a cache for external domanin and the LAN internal resolver, the problem that the output of the reverse resolver is wrong, it should return only the domain name; it seems that for some error the server doesn't find resources to answer correctly, but in the logs I have not fou...
IN NS ns.example.com. 131 IN PTR ns.example.com 102 IN PTR laptop.example.com 130 IN PTR server1.example.com You used a fully qualified domain name once, and then did not use it in any of the other cases. You clearly intend to use fully-qualified domain names here, given the question that you are asking. S...
bind9 reverse resolve problem
1,612,895,013,000
BIND9 v9.18 improves support for DNS-over-TLS (DoT) and DNS-over-HTTPS (DoH). However, while the docs explain how to use TLS for the server part, it does not reveal how to enable DNS-over-TLS for query forwarding. Does BIND9 v9.18 support it? How does the config snippet need to be tweaked to use DoT for the forwarders...
As this is the top hit on Google for configuring BIND9 to forward via DNS-over-TLS, here's how I've configured and tested on BIND 9.19.13, connecting to OpenDNS. I created a named.conf.dot in /etc/bind/ and referenced it via an include, but you could just as easily add this directly to named.conf tls OpenDNS-DoT { ...
How to use DNS-over-TLS with BIND9 forwarders
1,612,895,013,000
I'm wondering whether there is a command I can run to get a complete list of the domain names that my BIND9 currently manages on my master DNS server. Hypothetically, something such as: named --list And that would give me all the names of all the zones I have currently setup on that master. Now, the reason for askin...
First of all, usually, one only ask one question per post since its better for site lisibility and referencing... For your first question, you can ask bind to dump the zones it's currently managing, see the dumpdb command of rndc: dumpdb [-all|-cache|-zones|-adb|-bad|-fail] [view ...] Dump cache(s) ...
How do I list all the domain names that my BIND9 manages as a master?
1,612,895,013,000
I want to create a Debian based DNS Server to run BIND9. There is plenty of information on package dependencies. but it is all about how to install required packages when installing package-x.y.z. However, I cannot find anything about how to find out all the packages that are not required by package-x.y.z and uninstal...
For a stand-alone hardware server or VM: Step 1.) install Debian "base system" and nothing else. This should automatically provide you with a minimalist system that can still boot on its own and update itself over an internet connection, both of which I consider basic requirements for any sort of modern stand-alone in...
How do I determine the bare minimum Debian package requirements to run BIND9?
1,612,895,013,000
The Setup I have a containerized named service which is given their own IP with the following container file FROM alpine:latest RUN apk --no-cache add bind bind-tools bind-dnssec-tools bind-dnssec-root COPY --chmod=500 --chown=root:root init.sh /usr/sbin/init COPY --chmod=444 --chown=root:root bindetc/named.conf /et...
The dig command indicates your BIND is responding with a SERVFAIL error code, so it probably thinks your configuration has a fatal error. You really should see what log messages BIND is producing. Your zone declaration zone "." IN specifies your BIND is type master for the DNS root zone, so effectively you're telling ...
BIND9 as DNS server unable to fallback not defined directions to public DNS
1,612,895,013,000
I want to setup my Kerberos authentication using DNS lookups to define its servers. This can be done with URI records in the DNS database. There is given an example for KDC Discovery that looks like: _kerberos.EXAMPLE.COM URI 10 1 krb5srv:m:tcp:kdc1.example.com Now I try to add this record to the DNS database with ...
When you run nsupdate to add a record, you must specify a Time-To-Live value (TTL) for it to specify the maximum time the record can be cached by any resolver DNS server before querying an authoritative DNS server for an up-to-date version of the record again. This is true for all record types. The TTL value goes in b...
How to add URI record to bind9 DNS zone?
1,326,966,806,000
Don't you just love it when two commands each do one thing you want but neither do both? This is what cal does. Nice formatting. Lacks week numbers though: $ cal January 2012 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ...
If neither of these commands suit your needs you can use gcal to do what you want instead. Example $ gcal -K April 2014 Su Mo Tu We Th Fr Sa CW 1 2 3 4 5 13 6 7 8 9 10 11 12 14 13 14 15 16 17 18 19 15 20 21 22 23 24 25 26 16 27 28 29 30 17 Prints the week ...
Displaying week's number in certain format using ncal or cal
1,326,966,806,000
Given two numbers, month and year, how can I compute the first and the last day of that month ? My goal is to output these three lines: month / year (month in textual form but that is trivial) for each day of the month: name of the day of the week for the current day: Fri. & Sat. & Sun. [...] day number within the mo...
Some time ago I had similar issue. There is my solution: $ ./get_dates.sh 2012 07 The first day is 01.2012.07, Sunday The last day is 31.2012.07, Tuesday $ cal July 2012 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Script itself: #!/bin/bash # la...
First and last day of a month
1,326,966,806,000
I use alpine to read mails, and occasionally get emails from people with vCalendar files in attachment. Is there a command line utility that reads and displays vCalendar files?
I just googled and found vcal, a perl script for displaying vcal files. According to the man page it should do exactly what you need. There is also gcalcli a command line interface for google calendar which allows you to manage your google calendar. This may allow you to add events you received directly to your existi...
Command line utility to read vCalendar files
1,326,966,806,000
I'm looking to use the terminal more and more, and I'd like to find a terminal calendar app that can sync with Google calendar. I'm running ubuntu 14.04
Take a look at: gcalcli, and also: remind , which has PHP scripts to convert iCAL entries to Remind format.
Google calendar in the terminal
1,326,966,806,000
In gnome-shell's top bar, calendar items are shown. This is great. However, I miss the possibility to click onto an item and then see more details/or simply to be led to the specific event item in evolution or another preferred calendar application. The missing functionality is this: click on calendar item@top bar -->...
At the moment, this does not seem possible, because no API exists, that would allow gnomeshell to interact with events from e.g. evolution or gnome-calendar. see https://gitlab.gnome.org/GNOME/gnome-shell/issues/262#note_540721 For an issue that discussed this issue specifically, see https://gitlab.gnome.org/GNOME/gno...
How to make gnome-shell calendar open calendar app's event details when clicking onto calendar entry?
1,326,966,806,000
I need a calendar that stores everything locally as I work from places that don't have internet sometimes (I'm a virtual office). I really can't figure it out from reading what I can find about the subject. I am using Mint 12.
Mozilla Thunderbird plus lightning addon (official replacement for Sunbird which is no longer actively maintained)
Which application to use for a calendar?
1,326,966,806,000
I am an OpenBSD user and I am writing an awk script which automatically generates TeX course calendars for all courses that I teach. To obtain actual calendar out of the system I use Unix cal command. The problem is that the output of the cal command uses spaces as a delimiters which creates all sorts of problems when...
You could use sed for that. $ cal|sed -e '1n;s/\(..\)\(.\)/\1,\2/g' May 2012 Su, Mo, Tu, We, Th, Fr, Sa , , 1, 2, 3, 4, 5 6, 7, 8, 9, 10, 11, 12 13, 14, 15, 16, 17, 18, 19 20, 21, 22, 23, 24, 25, 26 27, 28, 29, 30, 31 1n prints the first line and moves to the next. The replacement then takes ...
Cal no space delimiter
1,326,966,806,000
In Debian Jessie 64-bit with Gnome 3.14.1, System Monitor shows evolution-calendar-factory process is using 1.1 GiB, and evolution-alarm-notify is using 826.6 MiB of virtual memory. I don't use no calendar or alarm, so isn't this somewhat out of purpose? Almost 2 GiB of memory (even virtual) for what, exactly? How can...
The virtual size or vsz of a process is not physical memory usage. Virtual memory can be allocated space and not used physical space. It can also be mmapped files which are already backed by disk. 64bit machines should be able to address 256TiB of virtual space. The virtual space metric was more important on 32 bit m...
Why does evolution-calendar-factory uses so much virtual memory?
1,326,966,806,000
Is there a CLI utility that allows one to sync up with their iCloud calendar (i.e., iPhone calendar on the cloud) to modify calendar events, etc.?
Another solution is suggested in this blog: I used a software from http://icloud.niftyside.com/ which I installed on my Uberspace. It was just unpacking it into a directory of the webserver and visiting the site. Then entering my credentials and I got all the URLs.
iCloud calendar command line utility
1,326,966,806,000
I have centos 7 with xfce. And I cannot find where is the necessary configuration file located to make Monday as first day of the week.
Thanks Artem S. Tashkinov, about links. I have found solution for centos: https://www.rosehosting.com/blog/how-to-set-up-system-locale-on-centos-7/ And the right command to change the locale for centos is: localectl set-locale LANG=en_GB.utf8 And after that it is necessary to restart the OS.
Configure first day of the week for xfce calendar in centos 7
1,326,966,806,000
I've configured 2-Step Verification with my Google accont (under https://myaccount.google.com/security). Emails with OAuth 2 seem to come through fine but I keep getting "Failed to connect calendar “[email protected] : MyName” Data source “MyName” does not support OAuth 2.0 authentication and Failed to connect add...
The "fix" that worked for me was to give up on Evolution and I switched to using Thunderbird instead
Evolution fails to connect to my Google calendar
1,326,966,806,000
Is it possible to install a php extension if PHP is already installed without having to rebuild PHP? I need to install the calendar extension but I don't like to build PHP, I just installed it with apt-get and did not builded it from source. https://www.php.net/manual/en/calendar.installation.php
If you installed PHP with apt-get, then you also need to install any required PHP modules in the same way. In your case you need to do this: apt-get install php-calendar
Install php extension if PHP is already installed
1,326,966,806,000
Hi I'm trying to launch cal with sxhkd. And it doesn't work, the terminal window is closed right after the command is executed. I tried to do it using the following: # launch urxvt 20x8 with cal super + c urxvt -geometry 20x8 -e cal -m I also tried to set bspwm to open the window as floating with this: bspc rule ...
You need to add -hold on urxvt, in order to not destroy its window when the program executed within it exits. urxvt -hold -geometry 20x8 -e cal -m
Launching urxvt with calendar (cal) using sxhkd
1,326,966,806,000
For Linux Mint 18.3, 32-bit, MATE desktop 1.18.0. In BASH, typing calendar produces the following error. rbv@rbv-F80Q ~ $ calendar In file included from /usr/share/calendar/calendar.all:23:0, from <stdin>:16: /usr/share/calendar/calendar.croatian:10:0: fatal error: hr_HR/calendar.all: No such file or ...
Well, I "fixed" the problem -- but I'm not happy with the way it ended up being fixed. The solution was to use Synaptic rather than apt-get on the command line to reinstall bsdmainutils. After doing that the error with calendar no longer occurred. But this reflects another recurring problem I'm having ala Synaptic wo...
calendar built-in displays error for "#include <hr_HR/calendar.all>"
1,326,966,806,000
I am a new laptop user after using an iMac desktop for about seven years. Over that time, I had become fairly reliant on Apple's services syncing between my iPhone and my iMac. Now that I'm on Fedora, I'm having to run two separate calendars and contact books, and manually update changes between the two. Is there a wa...
No, there is no clear way to integrate a Linux desktop with iCloud services, as Apple makes it difficult for anyone who is not using an Apple machine to use their services. ;)
Is it possible to integrate Apple iCloud services (e.g. contacts, calendars) with Fedora 20?
1,326,966,806,000
I recently moved to a different country and want to see the national holidays in the KDE calendar that shows when you click the clock (the Digital Clock 3 in the taskbar). However, the KDE cal only shows US holidays and I cannot find a way in the config and on the web to change that.
Click on the gear symbol near the top right of your screenshot to open the settings window of the KDE clock widget (which is responsible for the calendar display). Then select "Holidays" from the left column, and pick the country or countries you want.
Show Non-US holidays in the KDE Digital Clock calendar view
1,326,966,806,000
I'm trying to replace VEVENT to VTODO entries in an .ics file if it matches current date on another line (it was exported incorrectly): BEGIN:VCALENDAR BEGIN:VEVENT DTSTART:20220340T140000 END:VEVENT BEGIN:VEVENT DTSTART:20230620T193700 END:VEVENT BEGIN:VEVENT DTSTART:20210210T193800 END:VEVENT END:VCALENDAR The seco...
So the following should work: sed 'H;/BEGIN:VEVENT/h;/END:VEVENT/!d;x;/DTSTART:'"$(date +%Y%m%dT%H%M)"'/s/VEVENT/VTODO/g' org.ics Explanation: H: Appends to the hold space which creates kind of a buffer (space), then we do pattern matching /BEGIN:VEVENT/h and store it in the hold space, so now we run another pattern ...
Double match - substitute pattern on subsequent line if prevous line matches another pattern?
1,326,966,806,000
On my host I can show the adoption of the Gregorian calendar as it occurred for Great Britain and its colonies in 1752: $ cal september 1752 September 1752 Su Mo Tu We Th Fr Sa 1 2 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 The corresponding adoption for Denmark and Norway happened muc...
cal follows the POSIX specification for cal, which says as though the Gregorian calendar had been adopted on September 14, 1752. There’s no option to show the calendar with a different switch date. ncal supports different switch dates with the -s option: $ ncal -s DK february 1700 February 1700 Mo 5 12 Tu ...
Can `cal` show other Gregorian adoptions?
1,326,966,806,000
Is there such an application that updates your wallpaper according to your planner/calendar so that you can have a weekly view of your planner/calendar.
Yes, gcalcli with Conky. You can follow the detailed installation tutorial in this article
Auto-updating desktop calendar as wallpaper
1,453,145,646,000
I have found multiple examples of "esac" appearing at the end of a bash case statement but I have not found any clear documentation on it's use. The man page uses it, and even has an index on the word (https://www.gnu.org/software/bash/manual/bashref.html#index-esac), but does not define it's use. Is it the required...
Like fi for if and done for for, esac is the required way to end a case statement. esac is case spelled backward, rather like fi is if spelled backward. I don't know why the token ending a for block is not rof.
What does "esac" mean at the end of a bash case statement? Is it required?
1,453,145,646,000
I would like to do something like this where on Friday, the output is for both conditions that match: #!/bin/bash #!/bin/bash NOW=$(date +"%a") case $NOW in Mon) echo "Mon";; Tue|Wed|Thu|Fri) echo "Tue|Wed|Thu|Fri";; Fri|Sat|Sun) echo "Fri|Sat|Sun";; *) ;; esac As the code abo...
You can use the ;;& conjunction. From man bash: Using ;;& in place of ;; causes the shell to test the next pattern list in the statement, if any, and execute any associated list on a successful match. Ex. given $ cat myscript #!/bin/bash NOW=$(date -d "$1" +"%a") case $NOW in Mon) echo...
Possible to match multiple conditions in one case statement?
1,453,145,646,000
I am trying to use a variable consisting of different strings separated with a | as a case statement test. For example: string="\"foo\"|\"bar\"" read choice case $choice in $string) echo "You chose $choice";; *) echo "Bad choice!";; esac I want to be able to type foo or bar and execute the fir...
The bash manual states: case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac Each pattern examined is expanded using tilde expansion, parameter and variable expansion, arithmetic substitution, command substitution, and process substitution. No «Pathname expansion» Thus: a pattern is NOT expanded with...
How can I use a variable as a case condition?
1,453,145,646,000
In many languages it is possible to assign the result of a case/switch statement to a variable, rather than repeating the variable assignment many times within the case statement. Is it possible to do something like this in the Bash shell? color_code=$(case "$COLOR" in (red) 1;; (yellow) 2;; (green) 3;; (...
The variable=$(...) construct will take the standard output of whatever command is in $(...) and assign it to variable. Thus, to get variable assigned the way that you want, the values have to be sent to standard output. This is easily done with the echo command: color_code=$(case "$COLOR" in red) echo 1;; yel...
Variable assignment outside of case statement
1,453,145,646,000
I want to catch if a variable is multiline in a case statement in POSIX shell (dash). I tried this: q=' ' case "$q" in *$'\n'*) echo nl;; *) echo NO nl;; esac It returns nl in zsh but NO nl in dash. Thanks.
The dash shell does not have C-strings ($'...'). C-strings is an extension to the POSIX standard. You would have to use a literal newline. This is easier (and looks nicer) if you store the newline in a variable: #!/bin/dash nl=' ' for string; do case $string in *"$nl"*) printf '"%s" contai...
POSIX catch newline in case statement
1,453,145,646,000
My question is the zsh equivalent of the question asked here: How can I use a variable as a case condition? I would like to use a variable for the condition of a case statement in zsh. For example: input="foo" pattern="(foo|bar)" case $input in $pattern) echo "you sent foo or bar" ;; *) echo "foo or bar was n...
With this code saved to the file first, pattern=fo* input=foo case $input in $pattern) print T ;; fo*) print NIL ;; esac under -x we may observe that the variable appears as a quoted value while the raw expression does not: % zsh -x first +first:1> pattern='fo*' +first:2> input=foo +first:3> case foo (fo\...
Using a variable as a case condition in zsh
1,453,145,646,000
I'm trying to revive my rusty shell scripting skills, and I've run into a problem with case statements. My goal in the program below is to evaluate whether a user-supplied string begins with a capital or lowercase letter: # practicing case statements echo "enter a string" read yourstring echo -e "your string is $yours...
A simple answer, one which no doubt others can supersede. The character set ordering is now different depending on which locale is in use. The concept of locale was introduced to support different nationalities and their different languages. As you can see from the output of locale there are several different areas no...
How do I differentiate between uppercase and lowercase characters in a case statement?
1,453,145,646,000
I have the following code. read -p "Enter a word: " word case $word in [aeiou]* | [AEIOU]*) echo "The word begins with a vowel." ;; [0-9]*) echo "The word begins with a digit." ;; *[0-9]) echo "The word ends with a digit." ;; [aeiou]* && [AEIOU]* && *[0-9]) echo "The wo...
You are correct in that the standard definition of case does not allow for a AND operator in the pattern. You're also correct that trying to say "starts with a lower-case vowel AND starts with an upper-case vowel" would not match anything. Note also that you have your patterns & explanations reversed for the begins/en...
How to specify AND / OR operators (conditions) for case statement?
1,453,145,646,000
How add I add the condition in case whereby if it does not detect the required conditions, it will execute the command. My code: case $price in [0-9] | "." | "$") echo "Numbers, . , $ Only" ;; esac This command will execute if it detects numbers, "." and "$". How do change it in a sense if it does not det...
Add a default case: case $price in [0-9] | "." | "$") true ;; *) do-something ;; esac
How to negate a case pattern
1,453,145,646,000
Suppose one has the following case: #!/bin/sh case $1 in e|ex|exa|exam|examp|exampl|example) echo "OK" ;; t|te|tes|test) echo "Also OK" ;; *) echo "Error!" ;; esac Is there a more elegant and at the same time POSIX-compliant solution (i.e., no bash, zsh, etc.) to a situation like this? P.S. No need for exampleeee ...
What you can do is turn the comparison around: case "example" in "$1"*) echo OK ;; *) echo Error ;; esac With multiple words, you can stick with your original idea case "$1" in e|ex|exa|exam|examp|exampl|example) : ;; t|te|tes|test) : ;; f|fo|foo) : ;; *) echo error ;; esac or use a loop and a "boolean"...
How to match a specific word or its parts in a case statement?
1,453,145,646,000
I'm building a function that will calculate the gauge of wire required given amperage, distance(in feet), and allowable voltage drop. I can calculate the "circular mils" given those values and with that get the AWG requirement. I started building a large if elif statement to compare the circular mils to it's respected...
case $cmils in 3[2-9][0-9]|40[0-3]) cawg="25 AWG" ;; 40[4-9]|4[1-9][0-9]|50[0-9]) cawg="24 AWG" ;; 51[0-9]|6[0-3][0-9]|64[01]) cawg="23 AWG" ;;
Can I use comparison operators in case?
1,453,145,646,000
I want to check whether an argument to a shell script is a whole number (i.e., a non-negative integer: 0, 1, 2, 3, …, 17, …, 42, …, etc, but not 3.1416 or −5) expressed in decimal (so nothing like 0x11 or 0x2A).  How can I write a case statement using regex as condition (to match numbers)? I tried a few different ways...
case does not use regexes, it uses patterns For "1 or more digits", do this: shopt -s extglob ... case ${!i} in +([[:digit:]]) ) n=${!i} ;; ... If you want to use regular expressions, use the =~ operator within [[...]] if [[ ${!i} =~ ^[[:digit:]]+$ ]]; then n=${!i} else ...
Matching numbers with regex in case statement
1,453,145,646,000
How to use bash's "case" statement for "very specific" string patterns (multiple words, including spaces) ? The problem is: I receive a multi-word String from a function which is pretty specific, including a version number. The version number now changes from time to time. Instead of adding more and more specific stri...
You can use patterns in case statements, however you can't quote them so you have to escape whitespace. case ${OS} in "SUSE Linux Enterprise Server 11 SP4") echo "SLES11 detected." ;; Ubuntu\ 16.04.[3-4]\ LTS) echo "UBUNTU16 detected." ;; "CentOS Linux 7 (Core)") echo "CENTOS7 detected." ;; *) ...
how to use "joker" or wildcard in string patterns (spaces separated words) in a bash case statement?
1,453,145,646,000
Can I write a pattern in sed that matches patterns like Aa, Bb, Cc, etc. (i.e., Given an uppercase letter, it should match the corresponding lowercase letter) without enumerating all possibilities?
With perl, you can do: $ echo 'fooÉébAar' | perl -Mopen=locale -pe 's/([[:upper:]])(??{lc$^N})/<$&>/g' foo<Éé>b<Aa>r That uses the (??{code}) special perl operator, where you can dynamically specify the regexp to match on. Here lc$^N is the lowercase version of $^N, the last capture group. With GNU sed, you could do:...
Matching Uppercase/lowercase pairs with sed
1,453,145,646,000
If you write a Bash case statement, can you get the current match without explicitly assigning it to a variable ? Consider case $(some subshell command sequence) in one) stuff ;; *) stuff "$case_match";; esac I know that I can do the below but wanted to be more succinct. case_match=$(some subshell command sequenc...
You can with a bit of a hack, but you need to be sure you have an unset variable available. For example: unset foo # Make sure foo is unset, or at least set to the empty string case ${foo:-$(date +%m)} in 1) echo "Jan" ;; 2) echo "Feb" ;; # ... 11) echo "Nov" ;; 12) echo "Dec" ;; esac Here, foo is being u...
Is there a special variable containing a case statement match
1,453,145,646,000
summary: I'd like to use a bash case statement (in other code) to classify inputs as to whether they are a positive integer a negative integer zero an empty string a non-integer string Executable code follows, which is correctly classifying the following inputs: '' word a\nmultiline\nstring 2.1 -3 but is classifyi...
summary: Thanks to frostschutz for s/;&/;;&/ Freddy for the correct positive-integer pattern (guess I just got nightblind) I also added an additional clause to detect signed zeros, and a few more testcases. details: Save this improved code to a file (e.g. /tmp/integer_case_statement.sh), chmod it, and run it: #!/usr...
bash `case` statement to classify input as non- and integers
1,453,145,646,000
I want the user to type in -s followed by a number (e.g. -s 3). However, I can't seem to be passing another variable next to the existing -s. This is my code: echo choose read choice case $choice in -a) echo you chose a ;; -s $num) echo you chose the number $num #this is the -s number (...
There is almost certainly a better way to handle what you're doing. For starters you should avoid prompting the user for any input and instead make them provide arguments on the command line while running the program, but modifying your code to work: read -rp 'choose: ' choice case $choice in -a) echo 'you chos...
How to have a case parameter in shell scripting that is followed by a different parameter?
1,453,145,646,000
I have two digit month value (01 to 12). I need to get the three letter month abbreviation (like JAN, FEB, MAR etc.) I am able to get it in mixed case using the following command: date -d "20170711" | date +"%b" The output is "Jul" I want it to be "JUL". Is there a standard date option to get it?
Since you're dealing with a fairly static piece of information (barring more intercalary events), just use built-in shell commands: function capdate() { case "$1" in (01) printf "JAN";; (02) printf "FEB";; (03) printf "MAR";; (04) printf "APR";; (05) printf "MAY";; (06) printf "JUN";; (07) printf "JUL"...
How to get Month in all upper case
1,453,145,646,000
case "$1" in all) echo "$1" ;; [a-z][a-z][a-z][a-z][a-z][a-z]) echo "$1" ;; *) printf 'Invalid: %s\n' "$3" exit 1 ;; esac With this the only input accepted is all, and 6 characters. It won't accept 4 characters or more than 6. What I want to do here is to only allow characters, not digits or symbols, b...
You can do this with the standard pattern match by looking for any of the non-allowed characters, and rejecting the input if you find any. Or you can use extended globs (extglob) or regexes and explicitly make sure the whole string consists of characters that are allowed. #/bin/bash shopt -s extglob globasciiranges ca...
Case statement allow only alphabetic characters?
1,453,145,646,000
I wrote this code to echo a greeting depending on what time of day it is, but when I run it it doesn't show any errors but doesn't echo anything to the command line either. To try to troubleshoot I commented out everything and echoed just the time variable, which worked fine. So, what am I doing wrong?! #!/bin/bash ...
[...] introduces a character class, not an integer interval. So, [18-23] is identical to [138-2], which is the same as [13], as there's nothing between 8 and 2. You can use the following as a fix: case $time in #check if its morning 0?|1[01] ) echo "greeting 1";; #check if its afternoon 1[2-7] ) echo "greeti...
bash script with case statement not returning an output
1,453,145,646,000
I am writing a script which must accept a word from a limited predefined list as an argument. I also would like it to have completion. I'm storing list in a variable to avoid duplication between complete and case. So I've written this, completion does work, but case statement doesn't. Why? One can't just make case sta...
The list in complete -W list is interpreted as a $IFS delimited list, and it's the $IFS at the time of completion that is taken into account. So if you have: complete -W 'a b,c d' do_work do_work completion will offer a, b,c and d when $IFS contains space and a b and c d when $IFS contains , and not space. So it's m...
Bash, use case statement to check if the word is in the array
1,453,145,646,000
I'm having a hard time getting regex matches to work in a bash case statement. Example code: #!/bin/bash str=' word1 word2' echo "With grep:" echo "$str" |grep '^\s*\<word1\>' echo "With case:" case "$str" in '^\s*\<word1\>') echo "$str" ;; esac The example works with grep, but n...
That is because case doesn't use regex's but bash Pathname Expansion. You can learn more from bash man page or from Bash Reference Manual.
Regex in case statement [duplicate]
1,453,145,646,000
case "$1","$name" in -py | --python | --python3,*) if [[ "$name" =~ \..+$ ]]; then That doesn't catch stuff, which actually it should, like… USERNAME@HOSTNAME:~$ myscript --python surfer Funny thing: Simplify the multi pattern conditional to… --python,*) if [[ "$name" =~ \..+$ ]]; then and it works! With th...
The object of your case clause needs to match properly: case "$1","$name" in -py | --python | --python3,*) if [[ "$name" =~ \..+$ ]]; then should be case "$1","$name" in -py,* | --python,* | --python3,*) if [[ "$name" =~ \..+$ ]]; then But this could probably be more clearly expressed with less repetition as...
How is the correct syntax for a more complex case statement?
1,453,145,646,000
I often execute raw versions of remote Bash scripts in GitHub with this pattern: wget -O - https://raw.githubusercontent.com/<username>/<project>/<branch>/<path>/<file> | bash Generally I can do it without problems but since I have added the following code to a certain script I get an endless loop of echo (it often o...
Why would echo … happen "endlessly"? With wget … | bash you pipe wget to bash. The stdin of bash comes from wget. read reads from the same stdin. In general read reading from where the script comes from can consume parts of the script. In your case bash needs to read the whole while … done fragment (because e.g. it ...
Executing a remote script from a code repository causes endless loop
1,453,145,646,000
Hello ALL and thanks in advance. I have searched the forum for my situation and have been unable to locate a solution. I've got a script that I am passing arguments/options/parameters to at the command line. One of the values has a space in it, which I have put in double quotes. It might be easier to provide an ex...
Using $* or $@ unquoted never makes sense. "$*" is the concatenation of the positional parameters with the first character (or byte depending on the shell) of $IFS, "$@" is the list of positional parameters. When unquoted, it's the same but subject to split+glob (or only empty removal with zsh) like any other unquoted...
Passing options/args/parameters with spaces from the script to a function within
1,453,145,646,000
I am trying to use case to run this function if [[ $input -gt 0 || $input -eq 0 ]]; Is it possible to put in case to test the input for greater than 0 or equal to 0, or even 0 and less than 0, in case.
If only integers need to be handled and -0 is not need to be handled correctly, the following works: case "$input" in ''|*[!0-9-]*|[0-9-]*-*) echo "invalid input" ;; [0-9]*) echo "input >= 0" ;; -[1-9]*) echo "input < 0" ;; *) echo "invalid input" ;; esac But it is usually better to use if .. then ....
How to enter the condition to check 0 or more than 0 in case
1,453,145,646,000
Take a look at these attempts: $ case `true` in 0) echo success ;; *) echo fail ;; esac fail $ if `true` ; then > echo "success" > else > echo "fail" > fi success Now, why is the case statement failing? You might wonder why I don't just use the if statement and I shall explain. My command if complex and might return...
You can't use case $(somecommand) in ... to test the exit status of somecommand because the command substitution expands to the output of the command, not its exit status. Using $(true) doesn't work since true doesn't produce any output on standard output. You could do { somecommand; err="$?"; } || true case $err in...
How to use case statement to deal with multiple return values
1,453,145,646,000
I am trying to create a small script for creating simple, all-default Apache virtual host files (it should be used any time I establish a new web application). This script prompts me for the domain.tld of the web application and also for its database credentials, in verified read operations: read -p "Have you created...
How about a shell function? Like function read_n_verify { read -p "$2: " TMP1 read -p "$2 again: " TMP2 [ "$TMP1" != "$TMP2" ] && { echo "Values unmatched. Please try again."; return 2; } read "$1" <<< "$TMP1" } read_n_verify domain "Please enter the domain of your web application" read_n_verify ...
read-verification alternative (two prompts and if-then comparison alternative)
1,453,145,646,000
Today I have learned some tricks about menu option in command line. One of these was cat << EOF Some lines EOF read -n1 -s case $newvar in "1") echo ""; ecsa It's really magical. I can't find any description in man page about this option. How the input to read command was pushed into case option ? It usually...
The documentation of read notes that: If no names are supplied, the line read is assigned to the variable REPLY. From that point it's a normal case statement. -n1 reads a single byte and -s turns off terminal echo of the input.
What does "read -n1 -s" mean in this script?
1,453,145,646,000
I have a script loaded as a service in /etc/init.d/myfile When I try to start the service I get the error /etc/init.d/myservice: 21: /etc/init.d/myservice: Syntax error: "(" unexpected The issue seems to be with the process substitution <( in the source command. I use it without any problem in other scripts to extrac...
Bash, ksh93, zsh, and other recent shells support process substitution (the <(command) syntax), but it is a non-standard extension. Dash (which is /bin/sh on Ubuntu systems) doesn't support it, and bash when invoked as /bin/sh doesn't, either. If you have bash available, change the first line of your script to, for ex...
How to use process substitution within a case statement without getting syntax errors?
1,453,145,646,000
How to have spaces or tabs in the menu list? PS3='Please enter your choice: ' options=("Option 1" "Option 2" "Quit") select opt in "${options[@]}" do case $opt in "Option 1") echo "Your choise is 1" ;; "Option 2") echo "Your choise is 2" ...
The select statement in bash, which is what displays the menu, does not allow specifying an indent for the menu. Just a comment on the code: It's usually easier to let the case statement act on $REPLY rather than the variable with the selected string. It saves you from having to type in the strings twice. E.g. sele...
Linux - case command
1,453,145,646,000
FuzzyTime() { local tmp=$( date +%H ) case $((10#$tmp)) in [00-05] ) wtstr="why don't you go to bed" ;; [06-09] ) wtstr="I see your very eager to start the day" ;; [10-12] ) wtstr="and a very good day too you" ;; [13-18] ) wtstr="Good Afternoon" ...
[] denotes character ranges: [10-12] means digits 1 2 and the range between digits 0-1 -- this will match a single digit in range 0-2. Use simple comparisons with if-elif-else-fi: if [ "$tmp" -ge 0 ] && [ "$tmp" -le 5 ]; then echo "<0,5>" elif [ "$tmp" -ge 6 ] && [ "$tmp" -le 9 ]; then echo "<6,9>" #... else #...
case statement not behaving as expected (fuzzytime() function)
1,453,145,646,000
I have made a simple backup program for my bin folder. It works. Code and resultant STDOUT below. Using rsync to copy from local ~/bin folder to a /media/username/code/bin folder. The code works fine when only one result from mount | grep media but I can not quite fathom how to advance it to letting me select from mul...
Assuming your mount points don't contain whitespace you can use a script like this: #!/bin/bash check_media() { local found=(_ $(mount | awk '/media/{print $3}')) local index chosen until [[ "$chosen" =~ ^[0-9]+$ ]] && [[ "${chosen:-0}" -ge 1 ]] && [[ "${chosen:-0}" -lt ${#found[@]} ]] do for...
Selecting from various media using awk shell script
1,453,145,646,000
st.txt "failed" "aa" "2018-04-03T17:43:38Z" while read status name date; do case "$status" in 'aborted') echo -1 ;; "failed") echo -1 ;; 'succeeded') echo 0 ;; *) echo 0 esac exit 0 done < st.txt But I always get 0 as the output....
You should replace "failed" with "\"failed\"". It should be: while read status name date; do case "$status" in 'aborted') echo -1 ;; "\"failed\"") echo -1 ;; 'succeeded') echo 0 ;; *) echo 0 esac exit 0 ...
compare variable with string bash
1,405,814,980,000
I've seen the phrase "sh compatible" used usually in reference to shells. I'm not sure if it also applies to the programs that might be run from within shells. What does it mean for a shell or other program to be "sh compatible"? What would it mean to be "sh incompatible"? Edit: This question asking the difference bet...
Why are there so many “sh compatible” shells? The Bourne shell was first publicly released in 1979 as part of Unix V7. Since pretty much every Unix and Unix-like system descends from V7 Unix — even if only spiritually — the Bourne shell has been with us “forever.”¹ The Bourne shell actually replaced an earlier shell...
What does it mean to be "sh compatible"?
1,405,814,980,000
Will the executable of a small, extremely simple program, such as the one shown below, that is compiled on one flavor of Linux run on a different flavor? Or would it need to be recompiled? Does machine architecture matter in a case such as this? int main() { return (99); }
It depends. Something compiled for IA-32 (Intel 32-bit) may run on amd64 as Linux on Intel retains backwards compatibility with 32-bit applications (with suitable software installed). Here's your code compiled on RedHat 7.3 32-bit system (circa 2002, gcc version 2.96) and then the binary copied over to and run on a Ce...
Will a Linux executable compiled on one "flavor" of Linux run on a different one?
1,405,814,980,000
Node.js is very popular these days and I've been writing some scripts on it. Unfortunately, compatibility is a problem. Officially, the Node.js interpreter is supposed to be called node, but Debian and Ubuntu ship an executable called nodejs instead. I want portable scripts that Node.js can work with in as many situat...
The best I have come up with is this "two-line shebang" that really is a polyglot (Bourne shell / Node.js) script: #!/bin/sh ':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@" console.log('Hello world!'); The first line is, obviously, a Bourne shell shebang. Node.js bypasses any shebang that it finds, ...
Universal Node.js shebang?
1,405,814,980,000
I know there are many differences between OSX and Linux, but what makes them so totally different, that makes them fundamentally incompatible?
The whole ABI is different, not just the binary format (Mach-O versus ELF) as sepp2k mentioned. For example, while both Linux and Darwin/XNU (the kernel of OS X) use sc on PowerPC and int 0x80/sysenter/syscall on x86 for syscall entry, there's not much more in common from there on. Darwin directs negative syscall numb...
What makes OSX programs not runnable on Linux?
1,405,814,980,000
I've always been unlucky with regards to choosing a laptop that I can install Linux on. If it's not the wireless card that's not working out of the box, it's the video card. Also, I'm still not able to hibernate my computer, close the lid and resume where I left off at a later point. I always have to shut down the la...
I'm not sure what issues you're constantly experiencing but I run Gentoo on Lenovo Thinkpad without problems (fingerprint reader does not work) - with possible problems with removal of BKL in recent kernels (however 2.6.33 worked ok). Previously I used IBM Thinkpad. From my small experience with them: Thinkpads seems...
Which laptop is most compatible with Linux? [closed]
1,405,814,980,000
I have picked up -- probably on Usenet in the mid-1990s (!) -- that the construct export var=value is a Bashism, and that the portable expression is var=value export var I have been advocating this for years, but recently, somebody challenged me about it, and I really cannot find any documentation to back up what us...
export foo=bar was not supported by the Bourne shell (an old shell from the 70s from which modern sh implementations like ash/bash/ksh/yash/zsh derive). That was introduced by ksh. In the Bourne shell, you'd do: foo=bar export foo or: foo=bar; export foo or with set -k: export foo foo=bar Now, the behaviour of: ex...
Where is "export var=value" not available?
1,405,814,980,000
Of course, the standard way of testing if a file is empty is with test -s FILE, but one of our clients have received a script containing tests like this: RETVAL=`ls -s ./log/cr_trig.log | awk '{print $1}'` if test $RETVAL -ne 0 then echo "Badness: Log not empty" exit 25 fi with claims from the supplier that i...
Very interesting finding. Although I've never used ls -s to check whether a file is empty or not, I would have assumed, that it reports 0 for empty files, too. To your question: As Mat already commented, show them your test results. To explain the results to them, state that ls -s reports the amount of allocated block...
When does `ls -s` print "0"
1,405,814,980,000
RedHat and CentOS are binary compatible. So everything that works on the one will most probably work on the other (same RPMs, same libs, same versions, same dependencies)... Does the same hold true when comparing Ubuntu LTS with Debian? When trying to build up a mirror for Ubuntu LTS I noticed that the packages were c...
Ubuntu is derived from Sid, the unstable and rolling release version of Debian, every Ubuntu major release is nothing more than a Sid frozen at a certain point in time, and enriched with everything that transforms a Debian into an Ubuntu distribution. The answer to your question is no. Some libraries are also placed i...
Is Ubuntu LTS binary compatible with Debian?
1,405,814,980,000
This question answers why Linux can't run OSX apps, but is there some application similar to Wine that allows one to do so?
Since wine is a re-implementation of the Windows API - you're looking for a re-implementation of the Macintosh API or various "kits" that Apple provides to let OSX apps link to the system frameworks. I don't know of any that fit the bill. The only thing even close is the Chamelion Project which brings the UIKit from i...
Is there something like wine to run OSX apps on linux?
1,405,814,980,000
I'm curious about the file or symlink /etc/mtab. I believe this is a legacy mechanism. On every modern linux I've used this is a symbolic link to /proc/mounts and if mtab were to be a regular file on a "normal" file system /etc there would be challenges in making software work with mount namespaces. For a long time I'...
Should the use of /etc/mtab now be considered deprecated? Depends on who you ask. If you ask the authors of mount on Linux, yes; since 2018 it says … is completely disabled in compile time by default, because on current Linux systems it is better … I think that's pretty strong a statement. Prior to that, /etc/mtab...
Should the use of /etc/mtab now be considered deprecated?
1,405,814,980,000
Wikipedia says that dash executes faster than bash. My question is, if I set /bin/sh to dash, will all scripts that use /bin/sh in their shebang line that was intended for bash work under dash?
No, not all scripts intended for bash work with dash. A number of 'bashism' will not work in dash, such as C-style for loops and the double-bracket comparison operators. If you have a set of bash scripts that you want to use for dash, you may consider using checkbashisms. This tool will check your script for bash-on...
dash compatibility to bash
1,405,814,980,000
The C locale is defined to use the ASCII charset and POSIX does not provide a way to use a charset without changing the locale as well. What would happen if the encoding of C were switched to UTF-8 instead? The positive side would be that UTF-8 would become the default charset for any process, even system daemons. Obv...
The C locale is not the default locale. It is a locale that is guaranteed not to cause any “surprising” behavior. A number of commands have output of a guaranteed form (e.g. ps or df headers, date format) in the C or POSIX locale. For encodings (LC_CTYPE), it is guaranteed that [:alpha:] only contains the ASCII letter...
What would break if the C locale was UTF-8 instead of ASCII?
1,405,814,980,000
grep and sed are both described as using "basic regex" ("BRE") by default. BRE is well described here. But consider this output: # echo ' aaaaa ' | grep '\(aaaaa\|bbbbb\)' aaaaa # echo ' aaaaa ' | sed '/\(aaaaa\|bbbbb\)/ s/ /_/g' aaaaa In the first command, the \( ... \| ... \) syntax clearly acted ...
The description in the linked article is wrong. The actual POSIX definition states that: The interpretation of an ordinary character preceded by an unescaped <backslash> ( '\' ) is undefined, except for [(){}, digits and inside a bracket expression] And ordinary characters are defined as any except the BRE special c...
Does FreeBSD contain multiple variants of basic regex?
1,405,814,980,000
So, GNU awk has some extensions that are missing in the macOS awk. I want to be sure that my awk program also runs on the macOS awk (which I don't have access to). Now GNU awk has two different compatibility flags and I'm not sure which to use: --traditional and --posix. The latter is more strict. Does --traditional s...
No because MacOS implements features that are part of POSIX but weren't part of BWK awk (which gawk --traditional is intended to be compatible with) such as RE intervals so some language constructs don't mean the same across the 2 variants despite being valid in both. MacOS awk has bugs that aren't present in GNU awk...
GNU awk --traditional vs --posix
1,405,814,980,000
I occasionally do work on an older Solaris machine whose default version of grep is non-POSIX-compliant. This causes problems in my rc files because the default grep on the machine doesn't support the options I need. This is a machine at my place of work, and I'm not an admin; so I can't just install newer/better ver...
Several commercial Unix systems have backward-compatible utilities in /bin and /usr/bin, and a directory such as /usr/xpg4/bin that contain POSIX-compliant utilities. That way, old applications can stick to the old PATH with just /bin and /usr/bin, and newer applications use a PATH with the POSIX utilities first. Unle...
When to use XPG* version of a command?
1,405,814,980,000
This works perfectly well on any Linux : $ echo foo bar | sed -n '/foo/{/bar/{;p;}}' foo bar But fails on OSXs ancient BSD variant : ❯ echo foo bar | sed -n '/foo/{/bar/{;p;}}' sed: 1: "/foo/{/bar/{;p;}}": extra characters at the end of } command Am I missing some magical incantation? Is there a way to write t...
A sed editing command should be terminated by ; or a literal newline. GNU sed is very forgiving about this. Your script: /foo/{/bar/{;p;}} Expanded: /foo/{ /bar/{ p } } This would work as a sed script fed to sed through -f. If we make sure to replace newlines with ; (only needed at the end of comman...
BSD sed vs GNU - is it capable of nested matches?
1,405,814,980,000
Most software that runs on Linux can run on FreeBSD using an optional built-in compatibility layer. AIX is based on UNIX System V with BSD-compatible extensions. Is there a Linux compatibility layer in IBM AIX?
If you're thinking about running Linux binaries directly on AIX, then no there is no such feature (even if you can find binaries for the Power architecture for the Linux software you're trying to use). IBM does provide something called the AIX Toolbox for Linux Applications which should help porting software developed...
Linux compatibility layer for IBM AIX
1,405,814,980,000
Summary Is xargs -I s printf s more compatible than xargs -n 1 printf? Background To handle binary data that may include 0x00. I know how to convert binary data to text, like this: # make sure that you have done this: export LC_ALL=C od -A n -t x1 -v | # or -t o1 or -t u1 or whatever tr ABCDEF abcdef | # because POSIX...
xargs is probably the worst POSIX utility when it comes to portability (and interface design). I would stay away from it. How about: <file.hex awk -v q="'" -v ORS= ' BEGIN{ for (i=0; i<256; i++) c[sprintf("%02x", i)] = sprintf("\\%o", i) } NR % 50 == 1 {print sep"printf "q; sep = q"\n"} {print c[$0]} EN...
Is "xargs -I s printf s" more compatible than "xargs -n 1 printf"?
1,405,814,980,000
I want to install the Systemd-free Artix Linux, but noticed on DistroWatch that it misses many packages. Being an Arch based distribution, is it possible to install packages directly from Arch repository? May the fact that the two use two different init systems (OpenRC vs Systemd) be a problem?
I am not familiar with Artix; however it says on their Wikipedia page: Artix Linux has its own repos but most packages without systemd dependencies from Arch Linux repos and the Arch User Repository (AUR) can also be used. For packages that do rely on systemd, they would need to provide replacement packages that...
Can Systemd-free Artix Linux install packages from parent Arch Linux?
1,405,814,980,000
I was pondering getting a Google Chromecast or Cubetek Ezcast the other day, mostly for its novelty and maybe using it as a media player or device to conduct presentations. The way they set up, with the whole DIAL technology seems a little weird to me, but that may or may not be due to the reason I've never seen it in...
If the Cubetek Ezcast is like the Tronsmart EZcast, it probably has its own proprietary extension to uPnP protocol, which makes it near-unusable with anything but the EZcast software. I started digging into how to use it with Linux, but it didn't seem possible at the time. It's probably just a matter of time before so...
Chromecast / Cubetek Ezcast with Linux computer?
1,405,814,980,000
I was using the following command on my previous dedicated server with the same version of the FreeBSD installation: # uname -a FreeBSD 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Thu Sep 26 22:50:31 UTC 2013 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64 The command is following: netstat -ntu -f inet Out...
Up to FreeBSD 8.x (at least as of 8.4-RELEASE) it was possible to use the -t option with netstat -i/-I (show the state of all network interfaces/a specific interface). From FreeBSD 8.4-RELEASE netstat man: If -t is also present, show the contents of watchdog timers. This indeed had disappeared from FreeBSD 9.x (see F...
netstat command doesn't work anymore on the new dedicated server
1,405,814,980,000
I have some software that, among other things, needs to: Assess a file's rwxrwxrwx permissions; Work under every possible flavor of Unix and Linux you can find in the wild. Currently, it does that running the ls -l command. If the file is a symlink, I have to get the permissions of the target file. The -L switch wor...
Well, it's in the GNU, FreeBSD, OpenBSD, and general BSD ls implementations, so I'd say it's pretty likely to be anywhere.
How universal is the -L (dereference symlink) switch of the 'ls' command?