Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
34 views

exit code segment causes Bash prompt to freak out

My Bash prompt (based on mike kasberg's) generally works fine. But when I get an error code, and then write over to the next line, no newline is generated, so the text goes back over my previous ...
Smiley Tiger's user avatar
1 vote
0 answers
23 views

How to Identify and Terminate Idle tmux Sessions on a Debian Server

I have a Debian server with multiple tmux sessions running. Some of these sessions are idle and not running any active processes. How can I identify and terminate all tmux sessions that are not ...
maxime de smedt's user avatar
-1 votes
1 answer
44 views

Hide files and folders with same name

I ran into an issue where I had to restart my computer during a large extraction process involving many zip files :(. All the zip files contain a folder that has the name of the zip file (minus .zip) ...
Brian Jester's user avatar
0 votes
1 answer
49 views

How to use grep with a pipe symbol from the command line

Maybe I'm missing something very simple, but I don't seem to be able to use grep from the command line (in bash) where the search argument contains a vertical bar |. For example, grep a|b results in ...
Mr Lister's user avatar
  • 276
0 votes
1 answer
112 views

ls -ltr on the terminal lists the files but says "No such file or directory" in a shell script

I am new to Bash and am practicing some shell scripts. I wanted to write a script to list all the folders and their file count, if a root path is passed as a parameter value from the terminal. The ...
MNIA's user avatar
  • 1
17 votes
2 answers
4k views

How does ls know how to output its results?

While creating a bash script, I found that this code ls puts all files on one line: pi@raspberrypi:~/ptlrestinterface$ ls update.sh web.config MyApp.runtimeconfig.json still ls | head -n1 ...
Bart Friederichs's user avatar
0 votes
1 answer
33 views

sed does not consume rest of the line

I have one line of different words stored in a txt file N/A 9.0 Yes Yes N/A N/A N/A N/A 8.8 Yes Yes N/A N/A N/A N/A 8.7 Yes Yes N/A N/A N/A N/A 9.2 Yes Yes Yes Yes Yes Yes 9.1 Yes Yes Yes Yes Yes Yes ...
Cobra Kai Dojo's user avatar
0 votes
1 answer
76 views

Why do string variables in a bash script behave differently when echo'ed than they do when passed to an executable?

I have the following script: #!/bin/bash KID3=$(command -v kid3-cli) ARG1="-c 'get'" file="'1-01 - Johann Strauss - __Waldmeister___ Ouverture.flac'" echo Command: echo "$...
Frank van Wensveen's user avatar
1 vote
2 answers
146 views

FFMpeg: How to get the real return value in bash

I've always used ffmpeg via a cmd-script and I always could check the %ERRORLEVEL% which was always '0' on success or '!0' if an error occured. I'm trying to recode my cmd-scripts in bash (using msys2 ...
lhksoft's user avatar
  • 13
1 vote
0 answers
56 views

How to detox filenames in a bash script with no errors posted?

OS: Kubuntu 22.04.4 LTS x86_64 detox 1.4.5 To display above: neofetch --stdout |grep 'OS:' detox -V Here is a toxic filename, starts with s1: s1 Ä Ö Ü - ä ö ü Science & < > " 1 \ 2 ⁄ 3 ...
joseph22's user avatar
  • 367
0 votes
0 answers
82 views

How to launch another blank terminal in Kali Linux?

When I launch another terminal in Kali Linux with Cmd+Shift+T, I can see Shell No. 2 tab created. However, it is just a copy of Shell No. 1 and all the commands I ran on Shell No. 1 are visible on ...
kerblue's user avatar
2 votes
1 answer
117 views

Execute self-extracting bash script (with binary data appended) w/o saving it first

I have a self-extracting bash script (binary data appended to the end) like this: #!/bin/bash export TMPDIR=$(mktemp -d) ARCHIVE_START_LINE=$(...) # <omitted> # extracting data archive into a ...
Edward Ruchevits's user avatar
1 vote
1 answer
34 views

Moving directories that names end in - number matching a list.txt file

Graphic of Folder Structure : I am very new to advanced shell commands and scripting. I have fundamental terminal knowledge but have never attempted to create an automation like this before. A pure ...
Roco Gman's user avatar
10 votes
4 answers
2k views

Why does assigning a variable with command substitution, and then echoing that variable, always fail?

Why does the following not work in Bash? # Ensure TEST is unset export TEST='' echo "Hello world!" > test.txt && TEST="$(cat test.txt)" echo "$TEST" It always ...
Rob's user avatar
  • 103
1 vote
1 answer
97 views

Keep command line visible while scrolling

Unsure what the best place to tackle this would be .bashrc? Using different shell? Some fancy terminal emulator? Basically, I just want to keep seeing the command line / the last line of the terminal ...
sonofevil's user avatar
  • 127
0 votes
2 answers
226 views

Remove all files with name starting with single quote

I need to delete all files with these names (the quotes are part of the name): 'index.html?some-query-string' I tried with: rm \'index.html?*\' I get this error: rm: cannot remove ''\''index.html?*'...
Giacomo M's user avatar
  • 143
0 votes
1 answer
303 views

How do I make a command line always show in front of another app

let's say I only have one monitor and I open an IDE and a powershell window. I need to type words in the IDE's current tab while watching the conent of the command line. The problem I have is, ...
user22155685's user avatar
0 votes
1 answer
58 views

How to simply cleanup a filename?

OS: Kubuntu 22.04.4 LTS x86_64 to display above: neofetch --stdout |grep 'OS:' . How to simply cleanup a filename, not file contents? by removing from a filename: \n newlines \t tabs non printable ...
joseph22's user avatar
  • 367
0 votes
1 answer
236 views

Broken pipe, write error: An epidemic of unnecessary output

In the last few months, a problem has been spreading across my systems. That of broken pipe errors: # Solution: # silenced by replacing /bin/bzip2 -> bzip2-reference # to /bin/...
Hincor's user avatar
  • 1
0 votes
2 answers
46 views

An incorrect path is displayed in my custom command line prompt in bash

I would like to display the current and parent directories in my Linux command prompt. For example, if the current directory is /home/user/proj/src, I'd like the prompt to display proj/src. I found ...
Epsilon's user avatar
  • 103
2 votes
1 answer
51 views

How can I use the last changed file as an argument in linux?

I'm thinking of using the last changed file as an argument to commands like ls, echo, or cat, is there a simple and efficient way? this question arose when I was faced with analyzing the latest log ...
Ilgar's user avatar
  • 21
0 votes
1 answer
71 views

How to bring a job to foreground and then disable job control in bash?

I have a program running in a terminal window. I wish to disable the Ctrl+Z shortcut from suspending the process. After pressing Ctrl+Z, the command fg && set +m unfortunately disables job ...
SeparatedScheme's user avatar
0 votes
0 answers
54 views

Unsing ranger fm, how can I preview a file's thumbnail

I have images in HEIC format on my Synology NAS. I installed ranger in a docker container, and I can preview most videos and images (connecting using iTerm on mac), but HEIC is not supported. Synology ...
Adi's user avatar
  • 131
1 vote
2 answers
168 views

Why does zip --exclude only exclude files in the folder but not the folder itself?

I have the following command run in the bash shell which excludes the files in the folder scripts/. I tried the answer in Zip command for excluding directories and files but unfortunately it did not ...
Macky's user avatar
  • 93
0 votes
1 answer
77 views

remove duplicate character from string in pure bash - works in CLI but does not work in script

I want to remove all duplicate minuses from a string using pure bash (no sed/awk/etc). This works great in CLI: s="com---strig-3-1080p-----mp4" echo "${s//+(-)/-}" com-strig-3-...
Putnik's user avatar
  • 924
1 vote
0 answers
57 views

How to command pv (Pipe Viewer) to work with diff?

using: OS: Kubuntu 22.04.3 LTS x86_64 diff (GNU diffutils) 3.8 Copyright (C) 2021 Free Software Foundation, Inc. pv 1.8.0 Copyright 2023 Andrew Wood, pv = Pipe Viewer commands to display above: ...
joseph22's user avatar
  • 367
5 votes
1 answer
89 views

Less --hilite-unread prints carriage return ^M on blank lines

When printing files with Windows line endings (CRLF), less shows carriage return ^M in blank lines when option --hilite-unread is used. Lines with any text display correctly, skipping the carriage ...
Pawel's user avatar
  • 211
0 votes
1 answer
39 views

pipefail over ssh in linux

set -o pipefail is not getting evaluated correctly on the remote host if the set command is used in ssh command. Example ssh hostname "set -o pipefail; false | true; echo $?" - gives 0 (Not ...
Praneeth Gudumasu's user avatar
2 votes
2 answers
676 views

What is the command line shortcut to uncomment a previously commented line?

Alt+Shift+3 can only comment out, on subsequent invocations simply adding multiple comment characters (hashes) instead of toggling on / off the comment. How to uncomment a previously commented line or ...
mirekphd's user avatar
  • 157
0 votes
1 answer
99 views

Output of atool -l for large archives

The command atool -l my_archive prints the directory structure and files of my_archive to the command line. This is very handy if the archive contains only a few files. However, if there are many ...
Syd's user avatar
  • 1
0 votes
1 answer
82 views

What command to force dd output to a fixed width of 90 characters?

using: neofetch --stdout |grep 'OS:' OS: Kubuntu 22.04.3 LTS x86_64 dd --version dd (coreutils) 8.32 Background: re-purpose a disk = objective some script is being developed some script will delete ...
joseph22's user avatar
  • 367
0 votes
1 answer
47 views

How do I tell sed to stop trying to process commands?

Maybe I'm an idiot (this is the likely scenario, and I'm new to sed/bash scripting), but why does this work: NewVersion="$(echo $NewVersionFile | sed 's/^.*-\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')&...
sirphillystax's user avatar
0 votes
1 answer
1k views

"ls: cannot open directory '.': No such file or directory" in Git Bash (in VS Code terminal)

I am working in a Git Bash terminal within Visual Studio Code. For some reason, when the behavior of the terminal changed so that if I execute ls, the result is ls: cannot open directory '.': No such ...
Paul Wintz's user avatar
0 votes
2 answers
97 views

How to force declare -f to respect semicolons

Given the function hello () { echo "one"; echo "two"; } Inside a script I'm using cmd="$(declare -f hello); hello" then I try executing the command using bash -c $cmd, ...
weshouman's user avatar
  • 243
0 votes
1 answer
151 views

How to convert code from test format to if fi format?

I have code that opens a bash file in a terminal for entering the sudo password: test "$IN_TERM" || { export IN_TERM=1 konsole -e "$0" exit 0 } && true I need ...
moninah's user avatar
  • 35
1 vote
1 answer
272 views

Pipe in argument list of bash function

I'm using simple function to make my script more verbose. cmd() { echo "[#] $*" >&2 "$@" } When calling script with option -v all commands goes through cmd function: ...
yar83's user avatar
  • 13
0 votes
2 answers
88 views

switching from one directory to another directory with same name different path in command line

In Linux, I have two directories (just an example, this structure exist for every project checkout): /root/user/<project>/<parent_directory>/<long path>/test /root/user/<project&...
vijay's user avatar
  • 1
0 votes
2 answers
284 views

using bash to process a text file that consists of path names

I need some help with bash processing of a text file. In my effort to clean up decades worth of windows use I have written a simple command to find all the instances of a specific file - specifically ...
Sam's user avatar
  • 1
2 votes
2 answers
705 views

How can I setup ffmpeg to continuously produce 1 second videos from piped jpgs?

I am using ffmpeg on Ubuntu 22.04 to create 1 second mp4 videos from piped jpgs. The only issue that I have is that ffmpeg stops executing after the first set of jpgs is piped in. I need ffmpeg to ...
rickyz's user avatar
  • 23
0 votes
0 answers
198 views

Integrate aws-cli via docker to the linux command line

In order not to have too many local installations, I decided to encapsulate the aws and kubectl cli's to a docker container and integrate it via this script, which is accessible on the path: #!/bin/...
peez80's user avatar
  • 121
0 votes
0 answers
111 views

Long line in bash is partially hidden rather than wrapped

When I'm working on a server with a newer OS and bash version via SSH, I find that a long input line is partially hidden. I prefer to see a soft-wrapped line. I don't know if there are some options to ...
Alex's user avatar
  • 101
1 vote
1 answer
614 views

How do I change the background color for folders in PowerShell when invoking the "ls" command from WSL Interop?

I've installed the WslInterop module and exposed several commands from WSL2. I'm using Import-WslCommand "apt", "cat", "awk", "nano", "find", "...
fmotion1's user avatar
  • 127
0 votes
1 answer
281 views

How to nicely print time difference in bash?

In my bash script, I want to print the time that my set of commands took to execute. I'm doing this: #!/bin/bash start=$(date +%s) ./my-long-command.sh ./another-longcommand.sh echo "Completed, ...
yegor256's user avatar
  • 1,681
0 votes
1 answer
628 views

Can a linux command auto-login to a specific desktop environment session type

so a bit of context, i have my pc setup to start at TTY then when i want to go into a desktop environment i start the login manager. # Upon install setting the TTY as default start state sudo ...
noob456's user avatar
1 vote
0 answers
348 views

Creating a script for Windows 11 to gzip some files using 7-zip then move and replace them in another folder

I have the following directory structure: Parent Folder: Project Children of Project: data, rawData Inside of rawData I have: index.html, settings.html, user.html, script.js, style.css and other files....
George Florian's user avatar
1 vote
0 answers
605 views

How to remove current path and/or timestamp from the prompt in Mobaxterm

Software: MobaXTerm 23.2 OS: Windows 11 I'm using a Bash (Embedded) Local Shell Session in MobaXTerm. The prompt contains the date, the time stamp and the current folder, which leaves little space for ...
DeltaIV's user avatar
  • 437
0 votes
1 answer
217 views

Pass output of tmux command into later pane command

I'm trying to set up a keybind to toggle a top pane in the active window. The way I would like to do this is to: Check to see if a pane started with the top command exists in the current window If no ...
QtizedQ's user avatar
  • 103
3 votes
1 answer
117 views

Why can I ssh and return a result faster than Linux can with a bundled command?

I'm writing a short bash script that involves logging into roughly 100 nodes and counting the number of processes running in top with my username, and I'm trying to combine the ssh-related processes ...
Headphones's user avatar
1 vote
0 answers
153 views

How to change Adjust Scrollback - Konsole, via Bash?

with neofetch --stdout |grep 'OS:' OS: Kubuntu 22.04.3 LTS x86_64 Question: via Bash commands ... how to change Adjust Scrollback - Konsole from Fixed size = 1000 Lines __to Fixed size = 9999 Lines or ...
joseph22's user avatar
  • 367
1 vote
0 answers
207 views

How to use diff for files names, not file content, and echo "differences!"

Background: While comparing 2 directories, command1, from the internet: diff <(find "$DIR1" -printf '%P\n' | sort) <(find "$DIR2" -printf '%P\n' | sort) | grep '^[<>]' ...
joseph22's user avatar
  • 367

1
2 3 4 5
33