Questions tagged [bash]

Bash is a free shell for Unix-like operating systems from the GNU Project.

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

Positinal argument directly in bash for a command

No sure if this been asked before, but I want to create and use a positional argument directly in a oneliner. For instance i use du -sh together with a pipe a lot: du -sh /opt/directory/* |sort -h If ...
hrdy's user avatar
  • 75
1 vote
1 answer
1k views

How to get all IP addresses from connected devices with specific device name?

I'm making Bash script for automation and would like to get all IP addresses from connected devices with specific device name? For example I have 10 devices connected to Wi-Fi. All with same device ...
Sasha Milic's user avatar
0 votes
1 answer
3k views

tar command not working

I'm trying to figure out why is the following tar command not working - I've tried the following 2 versions & both don't work - Version 1 tar -c --use-compress-program=pigz -f /home/jhonst/...
usert4jju7's user avatar
-2 votes
1 answer
1k views

List/Print oldest and newest file in each directory

Could use a bit of help guys. I need to produce a report for the oldest and newest files that are residing in each unix directory The structure is simple Main folder with multiple subfolders that ...
Tom Tom's user avatar
4 votes
3 answers
398 views

How can I delete all files that have names not ending on exactly 2 digits?

I am currently trying to delete several files. I want to delete all files with file names that do not end on two digits (and when I say ending on two digits I mean it disregarding the .txt file ...
HaskellNoob's user avatar
3 votes
1 answer
636 views

Why the shell of MSYS2 can find binary files without "exe" extension in the folder /usr/bin

In MSYS2, for the binary files in the folder /usr/bin, I find that I can call them by "name" or "name.exe". However, in the Windows file system, there are only binary files with &...
myy1966's user avatar
  • 31
0 votes
0 answers
283 views

Bash check array membership with regex

I have just started bash scripting as of this morning, so forgive me for my less-than-adequate skills. I have a GitHub action where I scp files which have changed on a push event to the production ...
Noah Broyles's user avatar
0 votes
1 answer
711 views

Bash script using Curl to output http status code fails with "could not resolve host"

I'm new to bash scripting and I keep getting "could not resolve host" when running the following script. I know it must be a slash or comma, but I have tried everything and can't figure it ...
Carlos Hurtado's user avatar
1 vote
1 answer
337 views

Move files to new folderif string matches

I'm trying to go through a number of folders and check their contents. If one or more of the files inside matches any of the strings in a given list, I would like to move those files to a new folder. ...
Oiko's user avatar
  • 11
0 votes
2 answers
160 views

Bash terminal command to be repeated after an activity no longer foreground

so the context: I want to make a bash terminal command that will launch VLC to stream a video, and then when VLC is no longer in the foreground (VLC automatically goes to the background when the ...
orangpelupa's user avatar
1 vote
1 answer
2k views

Understanding how pgrep determines process IDs

I'm currently refactoring a script that works well if executed in terminal directly but exits early due to a process check if executed from crontab. This early termination is caused by code using a ps ...
William's user avatar
  • 13
0 votes
1 answer
103 views

How to test if a specific process ID is a terminal?

I'm writing a convenience script that will allow me to bring up an existing terminal upon pressing a keyboard shortcut, and spawn a new one if none currently exists. Ideally, this would be agnostic to ...
ijustlovemath's user avatar
1 vote
2 answers
7k views

Open git bash in current directory

Previously when I was in a directory, I clicked 'git bash here' and it would open in that directory. Now it opens my home directory. How can I fix this?
Joeri's user avatar
  • 11
0 votes
1 answer
245 views

Bash String char assignment using position index

Is it possible to change the string char using position index. For ex: Myvar="abcd" echo ${Myvar:0:1} gives the first char 'a' Can I change the first char to 'z'? Simply trying to assign ...
hithesh's user avatar
  • 115
0 votes
1 answer
67 views

Cannot disinstall PostgreSql by Script Bash - Linux - Must not open dialog confirmation

My goal is to uninstall PostgreSql (installed on a Linux host- Ubuntu 18.04 LTS) using a bash script file. I use the following command: apt remove --purge -y postgresql-12 && apt autoremove -y ...
Fausto70's user avatar
  • 111
0 votes
2 answers
385 views

fsck from initramfs console with 'f' key not working

My ubuntu laptop is dropping to initramfs console due to file system errors. I need to do 'fsck' manually. But the letter 'f' is not working in my keyboard. Right now I can't get a new keyboard. Is ...
kiran_g's user avatar
  • 105
0 votes
1 answer
208 views

How to copy hidden file names to a text file in unix?

I have several directories which contain hidden empty files. I need the name of these file names themselves, so I need to write the filenames to a txt file. My script looks like this: cd /z/...
Fnechz's user avatar
  • 1
0 votes
1 answer
152 views

How to convert with ease, a Newline List into a Column List?

. Here are the worst 200 passwords of 2020. https://nordpass.com/most-common-passwords-list/ What is an easy way to convert? After copying and pasting 200 rows from above web page ... into file1.txt ...
joseph22's user avatar
  • 347
1 vote
1 answer
309 views

regex in find doesn't accept the or operator in group

I'm trying to delete all files and directories in a parent directory, with the exclusion of some directories and their content. For this I use find in a bash script on MacOS. It works if I exclude ...
Philipp's user avatar
  • 13
1 vote
1 answer
300 views

How to distinguish between Rsync and SSH access in a “.bashrc” script

I have the following .bashrc on a remote host: #!/bin/bash DEFAULT=$PS1 PS1="\h:\w\$ " source ~/.bash_aliases if [[ $(hostname -s) = host_name ]]; then source /path/somescript.sh ...
simona's user avatar
  • 207
0 votes
1 answer
869 views

Bashrc not able to chain commands anymore using && or ;

You guys are my last resort. I've got a bashrc file with all kinds of commands in it. A lot of them are variations to this alias test=' test1 && test2 ' alias test1=' echo "i hope&...
S.J.'s user avatar
  • 13
0 votes
0 answers
243 views

Restrict commands in Linux shell

Is there an option like Set-ExecutionPolicy in Linux shell which can be used to restrict commands and scripts? Set-ExecutionPolicy is used in PowerShell: https://docs.microsoft.com/en-us/powershell/...
Prayank's user avatar
  • 101
0 votes
2 answers
514 views

How to delete any files that have not been used (access, change or modify) in X years

i run this command find BAR -type f -mtime +1095 # older than 3 years and find this file: BAR/foo.pdf So i run this: stat BAR/foo.pdf Access: 2020-01-03 01:32:05.584393000 -0500 Modification: 2017-...
acgbox's user avatar
  • 775
1 vote
1 answer
2k views

How to disable ssh non-interactive commands from the server side?

Currently I have a server with openssh7.1 installed, which supports non-interactive commands like : ssh user@server ls. Is there a way to disable such type of command on the server side?
cancantian's user avatar
1 vote
0 answers
63 views

Map network drive automatically via ps1 - not working

I have a network drive (Z:, dedicated server) from which I am running all my development applications. Every now and then Windows 10 loses the ability to access the drive, in which case I typically ...
Hewe's user avatar
  • 31
1 vote
0 answers
2k views

7z missing volume .r00

Some .rar files by volume do not end in .r00 or similar. then the following happens: If I run in command line: 7z x -y -pfoo "file (1).rar" And it is a file per volume, but the next volume ...
acgbox's user avatar
  • 775
0 votes
0 answers
709 views

Access root parent directory on Chromebook from different computer

I am trying to access all of the files on my Chromebook from a different computer. From the Chromebook, I can access all of the local files that I have created or downloaded, just not the ones that I ...
SteepAtticStairs's user avatar
1 vote
1 answer
3k views

Run 8 commands in parallel in equalized tmux panes

I have a monitoring utility that consists of 8 individual utilities, to monitor multiple aspects of a system. All of them kind of work like htop, in that they rewrite the screen periodically instead ...
user2741831's user avatar
0 votes
1 answer
874 views

Bash on MacOS doesn't seem to store history?

So I'm trying to teach myself Unix and I changed my MacOS terminal shell from the default zsh to bash, because the Coursera courses that I studied use Bash scripting and so does the First Semester in ...
jxhyc's user avatar
  • 553
0 votes
1 answer
52 views

Does bash shell interpret usage of quotation mark inconsistently?

Here is my code, I'n on a Macbook Pro mid-2014 updated to the latest. I use Bash 5.1.8 apples-MacBook-Pro:Documents apple$ egrep s* states.txt apples-MacBook-Pro:Documents apple$ egrep "s*" ...
jxhyc's user avatar
  • 553
1 vote
1 answer
893 views

Script in crontab only partially executed

My scenario: I've some python scripts on a raspberry pi. They behave like a service, they run forever without exiting and process signals. They are meant to run in the background, writing some values ...
xph's user avatar
  • 360
17 votes
4 answers
5k views

What does "2>&1" do when posted BEFORE 1>x?

I know what this command does: command 1>/dev/null 2>&1 But what, if anything, does the following do? command 2>&1 1>/dev/null I still see standard error output with the second ...
hanshenrik's user avatar
  • 1,665
1 vote
1 answer
2k views

How to make apache service run continuously from script file from docker?

I am trying to run apache2 service from .sh script from dockerfile. The 'sh' script contains 3 executable commands which is presented as below: #!/bin/bash export DISPLAY=:0.0 echo "pvw ...
rasunag27's user avatar
0 votes
1 answer
2k views

When I use Ctrl+R to search, the text "(reverse-i-search)" appears in the command

I don't know how to explain this one. When I use the Ctrl+R command in bash to reverse-search through commands, the actual text of the reverse search appears in the command itself. E.g., if I type ...
quant's user avatar
  • 484
1 vote
0 answers
72 views

A true read-only bash?

I've been looking for a true read-only version bash that we can provide to our auditors for view only permission in the Linux system. Our OS is CentOS 7 to be more specific. We want to disallow user ...
Bob's user avatar
  • 121
2 votes
1 answer
329 views

Is it possible to conditionally enable or disable filters/streams with user input?

I have a Bash script that runs FFmpeg on a given video file and - along with lots of other things - adds a PNG watermark to it using an overlay. I'd like to be able to only apply the watermark on some ...
Hashim Aziz's user avatar
  • 12.7k
1 vote
2 answers
80 views

How can I use the result of file parsing as an argument to a bash command?

I use Linux and want to use a program named Trelby to open directly the latest saved file. The latest saved file is stored in the seventh line of the file /home/me/.trelby/state, which looks like this:...
black-clover's user avatar
0 votes
0 answers
563 views

How can I add a function inside my .bash_profile?

I need to use a modified grep function to find certain jobs on our cronjob repositories (cvs & git) in a more automated way. So I got these functions already made for that job, but not sure how ...
Gabe Saucedo's user avatar
1 vote
1 answer
2k views

How to download the latest release from github and extract the zip in a folder using bash

I want to write a bash script to download the latest release from a github repo and extract the downloaded zip into a particular directory. From this gist I am able to download the zip file. The shell ...
k-c's user avatar
  • 13
2 votes
1 answer
2k views

Why is my script running if run with cli but not with crontab?

On WSL Ubuntu 20.04 I have two scripts (one sh and one python) that run perfectly if I launch them with bash, but not with cron. The second (python) script is supposed to run just if the first (bash) ...
Saverio Guzzo's user avatar
0 votes
1 answer
115 views

Got daemonp error while installing doom

I am on Macos 10.14 and am trying to install Doom with Emacs. I've downloaded emacs with brew install --cask emacs, and it is at version GNU Emacs 27.2. I run the installation lines per doom's ...
Ross Jacobs's user avatar
0 votes
1 answer
136 views

supress iproute2 error message

iproute2 has a message on fail that I do not know how to suppress. I want to save the output of iproute2 to a variable for later use. if my network is up all is well and the output is something like: ...
posop's user avatar
  • 125
1 vote
1 answer
1k views

Keep Color output with grep at systemctl status

I'm trying to get the original color of the output of this command with grep: sudo systemctl status telegraf | grep -e ● -e Active Output of command with this command the output is red, but i want it ...
Tobias2001's user avatar
1 vote
1 answer
387 views

Fade in/out PNG watermark overlay on video

I have an FFmpeg command in a script that crossfades a main video with an outro and then overlays a semi-transparent PNG watermark on top of it. ffmpeg -y -i "$1" -i "outro.mp4" -i ...
Hashim Aziz's user avatar
  • 12.7k
1 vote
1 answer
2k views

Recovering deleted files deleted with Git Bash on Windows using rm -rf

While working in Git Bash on my Windows laptop, I accidently deleted important files and folders using rm -rf on C:>. Is there a way to restore them? Since the OS is Windows while tool is bash, ...
Prasad's user avatar
  • 11
1 vote
2 answers
4k views

WSL, Graphics Applications not working- Error: Can't open display: 0.0

I am having trouble with graphical applications and WSL. I have Ubuntu 20.04.3 with X11 installed; but am getting the following issue when I try to test with xeyes (the same happens with any other ...
George's user avatar
  • 121
0 votes
0 answers
90 views

Linux find subdomain nameservers

How can i find the nameservers of subdomains ? Is there any way to find it ? I need that because the users enter the subdomains with other extensions. For example: test.test.com.au test1.test.com ...
James001's user avatar
0 votes
1 answer
112 views

Why does autocomplete vary with environment variables in /bin/bash

Why does: vi $VIRTUAL_ENV/bin/postact<TAB> become vi \$VIRTUAL_ENV/bin/postactactivate on ubuntu 20.04 and vi $VIRTUAL_ENV/bin/postactactivate on macOS. The Ubuntu version ruins ...
boatcoder's user avatar
  • 542
0 votes
0 answers
11 views

Why does tailing logs with kubectl prevent pipe from producing output? [duplicate]

I'm trying to process logs while tailing them. This command works: kubectl logs "$pod" --tail=100 | egrep pattern | cut -d ' ' -f 1 But this command produces no output: kubectl logs "$...
Dmitry Minkovsky's user avatar
0 votes
1 answer
118 views

more is wrapping the lines

I found the below function online (thanks to whoever wrote it}. The problem seems to be more is wrapping the output. I like the option to view output page by page but do not like wrapping. How can I ...
justmeettheman's user avatar

1
19 20
21
22 23
235