How to get latest files based on lastmodified using unix - unit-testing

currently I'm using below command to get latest 4 files.
But this command also fetches directories...but i want to exclude directory. How to do?
ls -tr /home/user | tail -4

If you want just the files to show you can issue:
for i in `ls -tr /home/user`; do if test -f $i; then echo $i; fi done | tail -4
-f flag on test checks if argument is a file
-d flag on test checks if argument is a directory

Related

/bin/bash: no: command not found: when trying to use a make:model command with J.DepP

When trying to run a Makefile from J.DepP, I keep getting /bin/bash: no: command not found. Does anyone know how to fix this? Is there a no program to install?
// Command that fails (split into 2 lines for readability)
find /home/jdepp-2015-10-05/KNBC_v1.0_090925/corpus1 -type f -name "KN*" | LC_ALL=C sort | xargs cat |
no /home/jdepp-2015-10-05/tools/knbc2kyoto.py KNP | no /home/jdepp-2015-10-05/tools/replace_pos.py /home/linuxbrew/.linuxbrew/bin/mecab -d /home/linuxbrew/.linuxbrew/lib/mecab/dic/unidic > model/knbc/train.JDP.euc
/bin/bash: no: command not found
/bin/bash: no: command not found
xargs: cat: terminated by signal 13
make: *** [Makefile:948: knbc] Error 127
That is the error I'm getting, where it's trying to run the no command. When I type no in terminal, it doesn't exist. Line 948 of the Makefile is just the command above.
Has anyone successfully installed J.DepP and fixed this error?
This was actually an issue because python wasn't installed and J.DepP's makefile didn't return a fail for a critical dependency.
Install python, run make clean && ./configure and the issue with disappear.

DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it

I have a Dockerfile
FROM strimzi/kafka:0.20.1-kafka-2.6.0
USER root:root
RUN mkdir -p /opt/kafka/plugins/debezium
# Download, unpack, and place the debezium-connector-postgres folder into the /opt/kafka/plugins/debezium directory
RUN curl -s https://repo1.maven.org/maven2/io/debezium/debezium-connector-postgres/1.7.0.Final/debezium-connector-postgres-1.7.0.Final-plugin.tar.gz | tar xvz --transform 's/debezium-connector-postgres/debezium/' --directory /opt/kafka/plugins/
USER 1001
When I use hadolint on it by
hadolint Dockerfile
I got warning
Dockerfile:6 DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check
I know I have a pipe | in the line started with RUN.
However, I still really don't know how to fix based on this warning.
Oh, just found the solution in the wiki page at https://github.com/hadolint/hadolint/wiki/DL4006
Here is my fixed version:
FROM strimzi/kafka:0.20.1-kafka-2.6.0
USER root:root
RUN mkdir -p /opt/kafka/plugins/debezium
# Download, unpack, and place the debezium-connector-postgres folder into the /opt/kafka/plugins/debezium directory
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -s https://repo1.maven.org/maven2/io/debezium/debezium-connector-postgres/1.7.0.Final/debezium-connector-postgres-1.7.0.Final-plugin.tar.gz | tar xvz --transform 's/debezium-connector-postgres/debezium/' --directory /opt/kafka/plugins/
USER 1001
The reason adding SHELL ["/bin/bash", "-o", "pipefail", "-c"] is at https://github.com/docker/docker.github.io/blob/master/develop/develop-images/dockerfile_best-practices.md#using-pipes
Below is a copy:
Some RUN commands depend on the ability to pipe the output of one command into another, using the pipe character (|), as in the following example:
RUN wget -O - https://some.site | wc -l > /number
Docker executes these commands using the /bin/sh -c interpreter, which only
evaluates the exit code of the last operation in the pipe to determine success.
In the example above this build step succeeds and produces a new image so long
as the wc -l command succeeds, even if the wget command fails.
If you want the command to fail due to an error at any stage in the pipe,
prepend set -o pipefail && to ensure that an unexpected error prevents the
build from inadvertently succeeding. For example:
RUN set -o pipefail && wget -O - https://some.site | wc -l > /number
Not all shells support the -o pipefail option.
In cases such as the dash shell on
Debian-based images, consider using the exec form of RUN to explicitly
choose a shell that does support the pipefail option. For example:
RUN ["/bin/bash", "-c", "set -o pipefail && wget -O - https://some.site | wc -l > /number"]

ocamlc - compiling ocaml-wasm - Error: /usr/lib/ocaml/bigarray.cma is not a bytecode object file

I'm trying to make install ocaml-wasm 1.
Unfortunately the build is failing with the error-message:
Error: /usr/lib/ocaml/bigarray.cma is not a bytecode object file
Here's a Dockerfile so you may reproduce the error:
FROM base/archlinux
RUN pacman -Sy --noconfirm ocaml ocamlbuild wget unzip make
RUN wget https://github.com/WebAssembly/spec/archive/v1.0.zip
RUN unzip v1.0.zip
CMD cd spec-1.0; make -C interpreter install; bash
You may run it:
docker build -t ocaml-wasm . && docker run --rm -it ocaml-wasm
It should find it to produce the same error as above.
Here's the entire output of the make command:
make: Entering directory '/spec-1.0/interpreter'
ls util/*.ml* syntax/*.ml* binary/*.ml* text/*.ml* valid/*.ml* runtime/*.ml* exec/*.ml* script/*.ml* host/*.ml* main/*.ml* \
| sed 's:\(.*/\)\{0,1\}\(.*\)\.[^\.]*:\2:' \
| grep -v main \
| sort | uniq \
>wasm.mlpack
echo >_tags "true: bin_annot"
echo >>_tags "<{util,syntax,binary,text,valid,runtime,exec,script,host,main}/*.cmx>: for-pack(Wasm)"
ocamlbuild -cflags '-w +a-4-27-42-44-45 -warn-error +a' -I util -I syntax -I binary -I text -I valid -I runtime -I exec -I script -I host -I main -libs bigarray -quiet wasm.cmx
+ /usr/bin/ocamlc.opt -pack bigarray.cma -bin-annot util/lib.cmo binary/utf8.cmo exec/float.cmo exec/f32.cmo exec/f64.cmo exec/numeric_error.cmo exec/int.cmo exec/i32.cmo exec/i64.cmo syntax/types.cmo syntax/values.cmo runtime/memory.cmo util/source.cmo syntax/ast.cmo util/error.cmo binary/encode.cmo exec/i64_convert.cmo syntax/operators.cmo binary/decode.cmo script/script.cmo text/parser.cmo text/lexer.cmo text/parse.cmo util/sexpr.cmo text/arrange.cmo exec/i32_convert.cmo exec/f32_convert.cmo exec/f64_convert.cmo exec/eval_numeric.cmo runtime/func.cmo runtime/global.cmo runtime/table.cmo runtime/instance.cmo exec/eval.cmo host/env.cmo main/flags.cmo script/import.cmo script/js.cmo text/print.cmo valid/valid.cmo script/run.cmo host/spectest.cmo -o wasm.cmo
File "_none_", line 1:
Error: /usr/lib/ocaml/bigarray.cma is not a bytecode object file
Command exited with code 2.
make: *** [Makefile:83: _build/wasm.cmx] Error 10
rm wasm.mlpack _tags
make: Leaving directory '/spec-1.0/interpreter'
How do I get ocaml-wasm to compile?
I've seen 2, but the answer doesn't help me. I've not installed any non-standard binaries. Could the ocaml distribution on arch linux be broken?
I suspect that your ocamlbuild version is 0.13 (see ocamlbuild --version), which is known to have this issue. You should use 0.12 to avoid the problem.
ocamlbuild 0.13 is not package on opam because of this problem (so it's not visible to most users), but I hadn't considered that distribution packagers may decide to package it nonetheless.

while installing zamfoo on server it failed and I entered this command now unable to install or uninstall or reinstall

the three command i entered are
cd /usr/bin
mv perl perl-backup
ln -s /usr/bin/perl /usr/local/bin/perl
this is causing me error bad interpreter: too many levels of symbolic links
Please tell me how to undo this command
Since you only had problems with creating a symlink at the end, you should only need to undo your move, with:
mv perl-backup perl
You should look at the output of:
ls -l /usr/bin/perl /usr/local/bin/perl
to see if either of them are symlinks already.

Using a FilteredClassifier with a Bayesian Network in WEKA

I'm running WEKA from the command line to create a Bayesian network model for training, and then using this model to test on a separate data set. The Bayesian network uses the TAN search option with a simple estimator. My command line call for training looks like this:
java -cp weka.jar:mysql-connector-java-5.0.8-bin.jar
weka.classifiers.bayes.BayesNet -d BN_model -p 0 -distribution -t tr2.arff -D
-Q weka.classifiers.bayes.net.search.local.TAN -- -S BAYES
-E weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 1 > tr_preds
Now, I just realized I need to use a a FilteredClassifier since I want to add instance IDs to my test data. This is where I'm stuck. I run the following:
java -cp weka.jar:mysql-connector-java-5.0.8-bin.jar
weka.classifiers.meta.FilteredClassifier
-F weka.filters.unsupervised.attribute.Remove -R 1
-W weka.classifiers.bayes.BayesNet -d BN_model -p 1 -distribution -t tr2.arff -D
-Q weka.classifiers.bayes.net.search.local.TAN -- -S BAYES
-E weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 1 > tr_preds
and I get the following error:
Weka exception: Illegal options: -S BAYES
To trouble shoot, I removed all the fancy search options and estimators, and just ran the Bayesian Network classifier with default settings. This worked fine, but it's obviously not what I need. It's clear that I'm having issues constructing this command line statement properly.
Could you please advise what I'm doing wrong? Thanks so much!
Best,
Francisco
The problem is that your command line arguments are in a wrong order. Because -- -S BAYES is the first -- after -W, it thinks this option belongs to weka.classifiers.bayes.BayesNet, which is an illegal option. You forgot the -- after -W ... to specifiy the options of the classifier.
Also, general options like -t tr2.arff -d BN_model -p 1 -distribution were placed somewhere in the middle, it is better to place them after the class you're calling:
java -cp weka.jar:mysql-connector-java-5.0.8-bin.jar
weka.classifiers.meta.FilteredClassifier
-t tr2.arff -d BN_model -p 1 -distribution
-F "weka.filters.unsupervised.attribute.Remove -R 1"
-W weka.classifiers.bayes.BayesNet
-- -D -Q weka.classifiers.bayes.net.search.local.TAN
-- -S BAYES
-E weka.classifiers.bayes.net.estimate.SimpleEstimator
-- -A 1