Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
27
votes
6
answers
24245
views
Any options to replace GNU coreutils on Linux?
I've been thinking about discontinuing the use of GNU Coreutils on my Linux systems, but to be honest, unlike many other GNU components, I can't think of any alternatives *(on Linux)*. What alternatives are there to GNU coreutils? will I need more than one package? Links to the project are a must, b...
I've been thinking about discontinuing the use of GNU Coreutils on my Linux systems, but to be honest, unlike many other GNU components, I can't think of any alternatives *(on Linux)*. What alternatives are there to GNU coreutils? will I need more than one package? Links to the project are a must, bonus points for naming distro packages.
Also please don't suggest things unless you *know* they work on Linux, and can reference instructions. I doubt I'll be switching kernels soon, and I'm much too lazy for anything much beyond a straightforward
./configure; make; make install
. I'm certainly not going to hack C for it.
***warning:** if your distro uses coreutils removing them could break the way your distro functions. However not having them be first in your $PATH
shouldn't break things, as most scripts should use absolute paths.*
xenoterracide
(61203 rep)
Jan 20, 2011, 01:40 PM
• Last activity: Nov 2, 2024, 12:37 AM
3
votes
4
answers
3078
views
How to find files with specific extensions, while excluding some names in the current directory only?
I want to **find** some files, in a non GNU environment - in the current directory only - with extension **\*.ext1** and **\*.ext2**, - but not **name1.\*** or **name2.\*** The following command works, but may be not efficient, because the shell expands `./*` and **find** can get a huge list of file...
I want to **find** some files, in a non GNU environment
- in the current directory only
- with extension **\*.ext1** and **\*.ext2**,
- but not **name1.\*** or **name2.\***
The following command works, but may be not efficient, because the shell expands
./*
and **find** can get a huge list of files and directories.
find ./* -prune \( -name '*ext1' -o -name '*ext2' \) -a ! \( -name 'name1*' -o -name 'name2*' \)
**Update:**
I'm working on AIX, there is no **-maxdepth** option.
Mattia72
(173 rep)
Dec 7, 2016, 07:45 AM
• Last activity: Oct 8, 2021, 10:30 PM
10
votes
2
answers
5016
views
regular awk - easily sort array indexes to output them in the chosen order
[edit: clarified that I need an *in awk* solution, and corrected that I need to sort 'indexes' (or rather, output them in a sorted way) instead of the ambiguous 'values')] In awk, I often count things, or store a set of values, inside an array, using the values as indices (taking advantage of awk's...
[edit: clarified that I need an *in awk* solution, and corrected that I need to sort 'indexes' (or rather, output them in a sorted way) instead of the ambiguous 'values')]
In awk, I often count things, or store a set of values, inside an array, using the values as indices (taking advantage of awk's indexes_are_hashes mechanism)
For example: if I want to know how many different values of $2 I encountered, and how often each values were seen:
awk '
... several different treatments ...
{ count[$2]++ }
... other treatments ...
END { for(str in count) {
print "counted: " str " : " count[str] " times."
... and other lines underneath, with additional infos ...
}
}
'
The problem is that (non GNU, or other nicer versions) regular awk (and regular nawk) :
- [A] doesn't output the different values in the order it has 'encountered' them,
- [B] nor provide an easy way to go through the indexes either in numerical or alphabetical order
for [A]: not too difficult to do .. just have another array to index the "newly seen" entries.
the QUESTION is for [B]: **How can I do a simple call to sort to reorder the display of the different indexes?**
(note : I am aware that gnu awk has an "easy" way for [B]: https://www.gnu.org/software/gawk/manual/html_node/Controlling-Array-Traversal.html ... But I want the way to do something similar in regular awk/nawk !)
(ie: I need to do a loop to output the different indexes seen, sort them, re-read them [in an old awk...] into "something" ( ex: another array ordered_seen ?) and use that something to display the seen[s] in the chosen order. And this needs to be *inside awk* as under each indexes I often need to output a paragraph of additional infos. A "sort" outside of awk would reorder everything)
So far: I find no "axiomatic" one-liner (or n-liner?) way to do that.
I end up with a kludge that takes several lines, outputs each values to a file through sort, and then re-reads that sorted file and insert each line in order into a sorted_countindexes[n++], and then for(i=0;ifileA
printf 's f g r e d f g e z s d v f e z a d d g r f e a\ns d f e r\n'>fileB
# and the awk loop: It outputs in 'whatever order', I want in 'alphabetical order'
for f in file? ; do printf 'for file: %s: ' "$f"
tr ' ' '\n' < "$f" | awk '
{ count[$0]++ }
END { for(str in count){
printf("%s:%d ",str,count[str])
}; print ""
} '
done
#this outputs:
for file: fileA: d:3 e:5 f:3 g:1 r:4 s:6 z:2 a:5 b:1 c:3
for file: fileB: d:5 e:5 f:5 g:3 r:3 s:3 v:1 z:2 a:2
# I'd like to have the letters outputted in alphabetical order instead!
Olivier Dulac
(6580 rep)
Sep 17, 2020, 01:15 PM
• Last activity: Sep 18, 2020, 01:50 PM
7
votes
3
answers
6753
views
Calculate the date from 1125 days ago on non-GNU systems?
On the Unix Bash commandline, I want to calculate the date from 1125 days ago using the base operating system (e.g. No Perl or Python). On systems running [GNU Date][1], I can do something like this: ubuntu $ date --date="1125 days ago" Wed Nov 7 15:12:33 PST 2007 FreeBSD or MacOSX systems don't shi...
On the Unix Bash commandline, I want to calculate the date from 1125 days ago using the base operating system (e.g. No Perl or Python).
On systems running GNU Date , I can do something like this:
ubuntu $ date --date="1125 days ago"
Wed Nov 7 15:12:33 PST 2007
FreeBSD or MacOSX systems don't ship with GNU Date, and don't support values like "X days ago".
freebsd81 $ date --date="+1125 days ago"
date: illegal option -- -
I *can* calculate a date from a few days ago on a Mac or FreeBSD system, but this is limited to a few days:
# Today is really Dec 6, 2010. 4 days ago it was:
macosx $ TZ=GMT+96 date +%Y%m%d
20101202
# But that doesn't work if I want to see the date 8 days ago:
macosx $ TZ=GMT+192 date +%Y%m%d
20101206
Can I calculate old dates on non-GNU systems without delving into tools like Perl or Python? Or must I use a more powerful scripting language?
Stefan Lasiewski
(20733 rep)
Dec 6, 2010, 11:24 PM
• Last activity: Jan 23, 2019, 09:22 PM
1
votes
0
answers
64
views
How to interpret the explicit references to GNU in the LSB specifications?
The LSB is a specification, and as such, should be provider neutral. But it contains many “hard‑coded” reference to GNU at many places. Ex. the ELF Linux's specific entries `PT_GNU_STACK`, `PT_GNU_RELRO` and al., or with some libraries like `libgcc_s`. How these explicit references to GNU in the LSB...
The LSB is a specification, and as such, should be provider neutral. But it contains many “hard‑coded” reference to GNU at many places. Ex. the ELF Linux's specific entries
PT_GNU_STACK
, PT_GNU_RELRO
and al., or with some libraries like libgcc_s
. How these explicit references to GNU in the LSB should be interpreted?
* Is it there for historical reasons (like the MZ
magic in one of the Windows executable formats)?
* Is it there to designate GNU as a unique provider for some parts of conforming systems?
* Is it there as an acknowledgement of some role played (currently or in the paste) without any particular mandate?
I would not have asked this questions, if the references did not appeared in a standard specification, I mean, the questions should be understood in this particular context.
Hibou57
(955 rep)
Apr 18, 2013, 01:27 AM
• Last activity: Nov 5, 2013, 08:10 AM
Showing page 1 of 5 total questions