2022 Developer Survey is open! Take survey.

New answers tagged

3 votes
Accepted

Creating a tar.gz archive of multiple directories of different locations -- "tar: Cowardly refusing to create an empty archive"

Your command is conceptually equivalent to this: tar -czf test1.tar.gz -C ~/Downloads/dir1 "" -C ~/Documents/dir2 "" -C ~/dir3/dir4/dir5 "" In human terms: tar -czf ...
user avatar
  • 67k
0 votes

Creating a tar.gz archive of multiple directories of different locations -- "tar: Cowardly refusing to create an empty archive"

IMHO it is not good idea to provide absolute (in some degree) paths of archived files. Will be much better to use command: tar -czf /tmp/test1.tar.gz Downloads/dir1 Documents/dir2 dir3/dir4/dir5 ...
user avatar
2 votes

Creating a tar.gz archive of multiple directories of different locations -- "tar: Cowardly refusing to create an empty archive"

You are not providing the file arguments for tar to process. If you had provided a file argument that doesn't exist or even the empty string, tar would print no such file or directory and exit. For ...
user avatar
  • 6,280
0 votes

I3 WM bindsym giving error but in terminal, works fine

See https://i3wm.org/docs/userguide.html#exec and, semicolons have special meaning in i3: See [command_chaining] for details on the special meaning of ; (semicolon) and , (comma): they chain commands ...
user avatar
  • 5,958
-1 votes

Every row of a file is converted to a new file

while read line do finame=$(echo $line| awk '{print $NF}') echo $line >$finame done<filer output cat G1 1 315 4567 G1 cat G2 1 212 345 G2 cat G3 2 315 25674 G3 cat G4 3 12 235673 G4
user avatar
1 vote

How to create an ephemeral user-level systemd timer on the commandline without unit/timer files?

You're looking for systemd-run, specifically one of the timer-related options: --on-active=, --on-boot=, --on-startup=, --on-unit-active=, --on-unit-inactive= and --on-calendar=. Using a monotonic ...
user avatar
  • 111
0 votes

Removing multiple files with same prefix (argument list too long)

Commands to remove files start with a specific name: a) rm -rf <file name>* (in case it gives an error **Argument list too long** then use option b) b) find . -type f -name '<file name>*...
user avatar
4 votes
Accepted

Redirect the output to two different files, One should have new output whenever the commands execute and the other should have both new & old content

cmd | tee A.txt >> B.txt Or cmd | tee -a B.txt > A.txt Would tee (think of a plumber's T) cmd's output both into A.txt and in append mode into B.txt. With the zsh shell, you can also do: ...
user avatar
3 votes
Accepted

Run cargo command in subdirectories with user-specified arguments

The shell doesn't mess up with --. Just do: #! /bin/zsh - for toml (**/Cargo.toml(N.)) cargo -v "$@" --manifest-path $toml And call it as: that-script test -- --ignored Using zsh globbing ...
user avatar
1 vote
Accepted

Cannot append user to group

The useradd command is for adding a new user account. The usermod command is for modifying an existing user account - for example by adding it to a group usermod -aG group user
user avatar
  • 89.1k
2 votes

Every row of a file is converted to a new file

You are somewhat close. awk '{print > $0}' is equivalent to awk '{print $0 > $0}', which is easier to understand. If you print a line to file called by your desired 4'th column ($4) instead of ...
user avatar
  • 512
2 votes
Accepted

Every row of a file is converted to a new file

You can try by slightly change the awk script: awk '{print > $4}' XXXX.txt But be aware if in the source file there is row with same 4th column as other the end file will contain only the last row....
user avatar
0 votes

Manipulating X key and pointer grabs on the command line

based on the answers above the following commands helped me to identify all programs grabbing keyboard shortcuts: $ lsof -c Xorg | grep ".log" # find out the path for the Xorg log file Xorg ...
user avatar
2 votes

What is the colon in postgres' process command-lines?

Because as per its documentation: On most Unix platforms, PostgreSQL modifies its command title as reported by ps, so that individual server processes can readily be identified. This isn't unique to ...
user avatar
  • 33.5k
0 votes

What is the colon in postgres' process command-lines?

This is nothing but a visual separator, telling apart the main process from the sub-process.
user avatar
2 votes
Accepted

How to get around 403 errors on websites with text-based browsers?

Try changing your text web browsers User Agent to something modern, e.g. Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0 on lynx this is done using --useragent option ...
user avatar
1 vote
Accepted

Is there a command line application that can prettify text containing HTML + CSS + JS?

First install prettier "globally" using either npm or your Package manager. Using npm: npm install -g prettier To "prettify" CSS using "custom commands" with Geany: ...
user avatar
  • 23
3 votes

Add new lines based on the columns of a tab delimited file

You can do this using GNU sed making use of its extended regex mode -E to aid in writing somewhat easy-to-read regexes. sed -E ' s/\t/\n/2;T s/^([^\t]+\t).*\n/&\1/ P;D ' file Outputs: ...
user avatar
  • 5,343
4 votes

Add new lines based on the columns of a tab delimited file

With awk, loop for the fields after the first one, for every line, and print a new line for every field. awk -F'\t' -v OFS='\t' '{for (i=2;i<=NF;i++) print $1,$i}' file Output: 211845 032 215979 ...
user avatar
  • 6,280
0 votes

What is the difference between Halt and Shutdown commands?

Cheat sheet: halt # halts the system but does not power off the computer halt -p # halts + power off computer shutdown now # halts + power off computer shutdown # halts + ...
user avatar
  • 2,243
-1 votes

Is there a command to display colors when giving hex value in terminal?

In the KDE terminal program konsole version 21.12.3 (https://konsole.kde.org/), if you hover over a hex color code it will show you that color as a pop-up square.
user avatar
1 vote

Find how many words in a file contain a number in them?

I suspect you're not getting any matches because your shell is interpreting the brackets using its own syntactic rules. They need to be in quotes. But even if it weren't for that problem, yours would ...
user avatar
  • 7,117
0 votes
Accepted

What's a clean way to run a specific command C for each line L of a given file F and then move every L where C(L) ran unsuccesfully?

With zsh, you could do: while IFS= read -ru3 url; do curl -- $url print -ru $(( $? ? 4 : 5 )) -- $url done 3< urls 4> bad 5> good That way, the bad and good files are opened only once ...
user avatar
1 vote

What's a clean way to run a specific command C for each line L of a given file F and then move every L where C(L) ran unsuccesfully?

Using bash, you can loop for the urls and test the curl command, --fail option of curl seems to be good for use inside scripts, see: How to check whether a command such as curl completed without error ...
user avatar
  • 6,280
0 votes

Command line - save sub-strings conditionally

Using sed $ sed s'~\([0-9]\)/[^:]*:\(.*\)~echo \2 >> \1~e' file.txt $ cat 1 20020711 20020731
user avatar
  • 1,092
5 votes
Accepted

Command line - save sub-strings conditionally

With awk: awk -F'[:/]' '{print $NF > $1}' file We split the row using both / and : as separators. The last field ($NF) is what to print, and the first field ($1) is the output filename. After ...
user avatar
  • 6,280
1 vote

How can I use the terminal and track what is being changed?

That requires the program to specifically log what it is doing. In the cases you have noted you get the output in the terminal when you run it from the terminal. When you run them from a GNOME ...
user avatar
  • 843
1 vote
Accepted

How to redirect while ignoring some of the text

One option is to pipe the command through sed before redirecting to the file: sbcl --noinform --non-interactive --eval "(ql:quickload :lambda-calculus-compiler)" < test.lisp | sed '1,/...
user avatar
  • 7,117
0 votes

How to download all repositories of a GitHub account to my personal computer without using github cli?

If you do not like CLI interface open you browser, open URL: https://github.com/settings/admin and click on button "Start export: If you want automatic way use CLI You can use this answer as ...
user avatar
0 votes
Accepted

Dynamically generate arguments for python script input

you have multiple choices, since you already use sed, I would suggest python3 script.py $(sed -e '/^#/d' -e 's/=/ /' -e 's/^/--/' ${THIS_FILE_DIR}/model.conf ) where use -e to specify multiple sed ...
user avatar
  • 29.3k
-3 votes

When exactly would you use ".[^.]*" or ".??*" glob patterns?

In a Bash (@Linux]$ shopt -s dotglob (@Linux]$ shopt -s extglob (@Linux]$ shopt -s globstar (@Linux)$ ls -a . .. ...foo .foo1 a.c m.m subfolder (@Linux]$ ls !(.|..) ...foo .foo1 a.c m.m ...
user avatar
0 votes

How can I get a count of files in a directory using the command line?

I use this one, few examples: ls -Ap directory01/directory02 | grep -v /$ | wc -l ls -Ap directory01/directory02/exampl* | grep -v /$ | wc -l ls -Ap /home/directory01/directory02 | grep -...
user avatar
1 vote

How do I create a blank PDF from the command line?

With qpdf qpdf -empty -- vide.pdf result file size is 315 bytes
user avatar
4 votes
Accepted

List user and return non zero exit code if the user not in the system

A good way of testing whether a user exists on a system is by using getent. The getent utility can return various pieces of information from various "databases", for example, the passwd &...
user avatar
  • 268k
0 votes

How much disk space does a list of files use

If you can generate a list of files (or whatever) using find you can also: find {directory} {matching expression} -exec stat -c "%s" {} \; | awk 'BEGIN{total=0} {total=total+$1} END{print ...
user avatar
0 votes

How to grep a specific line _and_ the first line of a file?

This solution allows to use the real grep or any other filtering command. ps aux | { awk 'NR<=1 {print >"/dev/fd/3"; next}; {print}' | grep someApp ; } 3>&1 It should not have ...
user avatar
1 vote
Accepted

How does Input/Output Redirection work in Linux/Unix?

Option number 2: test.txt is opened, and cat is set up with its standard input pointing to that file. On Linux, you can see this by running $ touch /tmp/foo $ sleep 120 < /tmp/foo & [1] 3006118 ...
user avatar
0 votes

Programmatically change the playback speed (NOT pitch) in real-time

For readers in 2022 with mplayer (in my case installed via brew), put this in your terminal config (in my case .zshrc): alias mplayer="mplayer -af scaletempo=speed=tempo" then during ...
user avatar
  • 254
-1 votes

Failed to show the preferences dialog GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown

run this in your terminal, if your panel broken xfce4-panel --disable-wm-check
user avatar
2 votes
Accepted

What does Session ID mean within the pkill context?

The session id is the identifier of a process’ session. Sessions are a concept tied to shell job control, at a level above process groups; all processes in a given session share the same controlling ...
user avatar
0 votes

CLI tool that compress the given image, whatever file type the image is (png, jpg, gif, webp, svg)?

If you don't mind using SVG as an intermediary format, then inkscape may be useful. But you're probably looking for ImageMagick's convert. From the man page: convert-im6.q16(1) General ...
user avatar
  • 8,649
0 votes
Accepted

Instead of a single hostname specified on the command line, it reads in a list of multiple target IP addresses from a file

You seem to want to have "$1" represent a file containing a list of targets, instead of being just 1 target. So you will need to englob the main part in a loop ATHOSTFILE="$1" ...
user avatar
3 votes
Accepted

Pass text with unbalanced quotes as argument on command line

If that command line is preprocessed by the scheduler and it then sends it to a shell for execution (e.g. though sh -c), after doing a simple text replacement of {joboutput} with the actual text, then ...
user avatar
  • 115k
2 votes
Accepted

How to use wildcard for files without extension

* means zero or more of any character, . means the single character dot. So *.* means any names with a(t least one) dot in there somewhere. On Unix-likes, the dot is just a regular character in ...
user avatar
  • 115k
3 votes

How to use wildcard for files without extension

* does mean zero or more characters so *.* means some characters, followed by a dot, followed by more characters, so will match foo.bar, foo. .bar, foo.bar.baz, but not foobar, because the dot in the ...
user avatar
  • 156
0 votes

APT repositories on Android

Userland app is a good option in 2022 https://play.google.com/store/apps/details?id=tech.ula It runs full Linux distros or specific applications on top of Android. Install and uninstall like a ...
user avatar
  • 1
0 votes
Accepted

Get argument position given its value in a bash script

While it wouldn't surprise me if there were quicker, easier ways, something like this should work: #!/bin/bash pos=0 found=no for arg ; do let pos++ if [[ "$arg" == "hello" ...
user avatar
  • 7,117
1 vote

How to remember, which order grep and find takes the parameters?

grep and find I'm stumbling through, which order I should type the commands: When I should write the path and when I should write the flags, if it needs double quotations or not, etc. etc. The ...
user avatar
  • 28.8k
-1 votes
Accepted

Binding a utility to an ip/port

To answer myself; inetd was what I was looking for; launch a program to process the connection, e.g. netstat. Linux – Create custom inetd service Thank you for helping me.
user avatar
  • 7
2 votes
Accepted

how to grep the results (plural) of another command

If your shell offers "process substitution", try command2 | grep -f <(command1) If not, you can also pass the list of regexps on the command line using command substitution: command2 | ...
user avatar
  • 8,257

Top 50 recent answers are included