Tag Info

New answers tagged

1

Simple awk thing. Using some ANSI sequences for movement and clearing... #!/usr/bin/awk -f BEGIN { print "Stats:\n---------------------------------" } function clear() { for (k in ar) printf "\r\033[K\033[1A" } function stats() { for (k in ar) printf "%-10s: %d\n", k, ar[k] } /./{ clear() if (!ar[$0]) ar[$0]=1 ...


1

Here's a small Python 2 program that does what you want. The words are listed in chronological order of first appearance, i.e., each new word is added to the bottom of the list, but it would be easy to sort words alphabetically, or in order of number of occurrences. The output could be a little neater, eg if you know the maximum string length then the ...


3

To expand on what @Bratchley said in the comments, if you have your program's output printing to a file, then you can run then watch command in the terminal to get near-real-time view of the output by including the -n flag like so: watch -n 0.1 "cat yourprograms.log | sort | uniq -c | sort -rn" Note: The ' -n ' flag sets the refresh interval. The ...


0

Extending Clayton answer: tac $HISTFILE | awk '!x[$0]++' | tac | sponge $HISTFILE tac reverse the file, make sure you have installed moreutils so you have sponge available, otherwise use a temp file.


3

awk might be more up to the task awk '{sep=$3 in a?",":"";b[$3]++; a[$3]=a[$3]sep$1}; END{for (k in a) print k, b[k], a[k]}' file


1

With zsh, instead of: pax -w dir Use: pax -dw dir dir/**/*(D) You can do the same with recent versions of bash -O globstar -O dotglob with: pax -dw dir/** Or recent versions of FIGNORE='@(.|..)' ksh93 -o globstar with: pax -dw dir dir/** pax is the standard command to make tar files. The output goes to stdout. Shell globs are sorted by name. If ...


3

For a GNU tar: --sort=ORDER Specify the directory sorting order when reading directories. ORDER may be one of the following: `none' No directory sorting is performed. This is the default. `name' Sort the directory entries on name. The operating system may deliver directory entries in a more or less random order, and sorting them ...


0

tar itself cannot do this, so you have to create it from a correctly ordered list. In principle you could then use tar's -T option, but there is no way to specify that the filenames in that list should be NUL terminated. So if you have any filenames with newlines in them (which is allowed) this will just break. A better option is to use cpio to generate ...


1

The straightforward way : find . -maxdepth 1 -type d -name '.*' find . -maxdepth 1 -type d \! -name '.*' find . -maxdepth 1 -type f -name '.*' find . -maxdepth 1 -type f \! -name '.*'



Top 50 recent answers are included