Questions tagged [bash]
Bash is a free shell for Unix-like operating systems from the GNU Project.
11,722
questions
1
vote
0
answers
395
views
Bash: read from socket file descriptor returns always the same data instead of blocking
I have a postgres started like this:
exec 3< <(su -l postgres -c "/usr/local/pgsql/bin/postmaster -p '$port' -d 3 -D '$backupDir' 2>&1 & echo \$!")
This redirects all logs ...
1
vote
1
answer
751
views
GRUB2 - Select OS based on time (RegExp or other method)
I'm trying to make grub2 boot to Ubuntu when in a certain hour interval and otherwise to Windows. I'm trying to do this by editing /boot/grub/grub.cfg and changing which OS is being used as default on ...
1
vote
1
answer
411
views
Print sections in text file using awk and shell variables
I have a text file, materials.txt, with a large number of material definitions similar to this:
*FILESTART
line_a
line_b
line_c
*MAT_PLASTIC
1 property1 property2 property3
property4 ...
1
vote
0
answers
628
views
How to slice array of awk-output in bash?
Summary
Depending on what bash or awk version I have, I get different results when I try to slice an array that holds awk output. On older versions of bash and awk the "slice operation" ( e....
1
vote
0
answers
479
views
How can I use a serial connection as an output for a shell?
I have a serial device (/dev/ttyACM0), which is connected to the serial port of a microcontroller. The microcontroller draws text that it gets on that serial connection to a screen. I want to use that ...
1
vote
0
answers
37
views
How to change the target directory of target-csv when running tap-target script inside python? [closed]
I am trying to a script run.sh using python subprocess
The script creates a csv file and a state.json file in the cwd
This is the script(works fine when i run it from terminal) :
#!/bin/bash
export ...
1
vote
0
answers
702
views
Fuzzy finder script to search file contents while floating (i.e. in dmenu/rofi style)
I've been trying to create a script with the following functionality: I push a button in my window manager -> a fuzzy finder menu in floating mode pops up where I can type a keyword to search the ...
1
vote
0
answers
125
views
Unable to set python environments with old interpreters
I have installed virtualenvwrapper on Arch Linux, as well as the AUR repository python38 so I can set an environment and work with TensorFlow. I have set up .bashrc as usually recommended on the docs ...
1
vote
1
answer
350
views
How to customize the bash prompt in a way that doesn't squash venv
I was a long time tcsh user and I have used a custom prompt, which includes the date/time, host, and a largish path. In the past, when I've used venv, I would switch to bash first, just because ...
1
vote
0
answers
92
views
how to do netcat in a terminal
i have a program that is like a terminal that i want always on, how do i put it in a port through netcat so when i connect to that port i can write in the terminal and when i exit, the program doesn't ...
1
vote
0
answers
370
views
xterm text wrapping and reverse command search not working properly
My set up is: Arch Linux, i3, xterm. I would be happy to provide other details as well.
I have been facing this problem for quite sometime now. Here it is.
When there is certain text on the window and ...
1
vote
1
answer
468
views
How to collapse folders and subfolders with the same name?
I have a huge archive of files on which I've screwed up downloading from sftp and the folder structure is incorrect.
The result is many cases where folders are one level deeper than they should be (...
1
vote
0
answers
1k
views
Copying a file while its being written to (in Linux)
I am in a year-long Twitter research project, and I collect tweets via Twitters API and Twarc.
In short, this writes a new tweet as a new line to one specified file, roughly one per second at night, ...
1
vote
1
answer
497
views
Migrating from bash to zsh - where are the packages I installed?
I am new to a lot of this, so forgive me if I don't understand this 100%. I have just installed macOS Big Sur, then installed a few tools in my bash terminal (homebrew, nvm, npm + node, yarn, gatsby ...
1
vote
0
answers
612
views
print XPath for match using xmlstarlet?
I would like to iterate over many xml files to fix outdated configuration entries by getting all matches and replacing then in a second step every entry by updated strings (multiline scripts in this ...
1
vote
0
answers
50
views
Bash script whitespace compliant
I have an huge amount of file to organize, they are a JPG files in an absurd folders structure.
I need to move all files from its actual position to an organized folder structure, saving its actually ...
1
vote
0
answers
139
views
bash grep not finding all instances of gene
I have a file1 which has gene names:
Appl
Bsg
mt:CoI
mt:CoII
mt:CoIII
I have file2 which has all matches of those gene names in the genome:
"FBgn0000108"; "Appl";
"...
1
vote
1
answer
39
views
how do I find out the PID of this that I ran by typing ./x264 --threads=1 -o vidz.mkv paris_cif.y4m?
I already ran
./x264 --threads=1 -o vidz.mkv paris_cif.y4m
and it encodes a video from input file paris_cif.y4m to output file vidz.mkv
Now I want to know the PID of that.
1
vote
1
answer
6k
views
Can’t boot to Windows, stuck on Grub BASH-like command line
I have installed Grub in Windows through bootcamp on a MacBook, to dual boot ChromeOS and windows .
However after repairing the hard disk in MacOS disk utility grub shows the command prompt interface ...
1
vote
1
answer
49
views
Match contents of file to directory and delete it
Let's say I ran a command that redirected certain files from a directory into a file. Now i want to delete those files from the directory. How would i accomplish this. I'm thinking that i would maybe ...
1
vote
1
answer
2k
views
iTerm2 + oh-my-bash: iTerm2 shell-integration not working
I cannot get iTerm2's shell integration work with oh-my-bash. I already tried the suggestions in the existing posts but without luck. My configuration looks as follow:
iTerm2 profile
General -> ...
1
vote
0
answers
68
views
How to get output from the console and act on it without expect?
I have read in another question’s answer that if you want to use expect like this:
git clone ssh://[email protected]/myproject.git
expect "Enter passphrase for key..."
send "myPassword\r&...
1
vote
0
answers
4k
views
How to use sftp 'ls' command to find all files in subdirectories including files beginning with '.'
I need to obtain a list of files contained within subdirectories including filenames starting with '.' using the sftp ls command. For example my directory structure on the remote is:
root_folder
|
...
1
vote
0
answers
830
views
How to escape slashes in bash alias name?
I want to make an alias like this:
alias /sbin/init="/path/to/my/script/sh"
However, when I try to source my .bashrc, it throws an error:
-bash: alias: `/sbin/init': invalid alias name
How ...
1
vote
0
answers
138
views
putty won't close after starting script with -m option
with this script
putty -ssh user@host -i C:\Users\TheUser\.ssh\id_rsa.ppk -m C:\users\TheUser\desktop\script.txt
exit
I tried to automate a network shutdown after a backup on the Remote NAS, ...
1
vote
1
answer
2k
views
sed, passing capturing group value to subcommand
Consider following example:
echo abc=123 | sed "s/\([^=]*\)=\(.*\)/\1=\2/"
outputs
abc=123
ie. the same as input. We matched everything up until symbol = as capturing group 1, and ...
1
vote
1
answer
562
views
How can I sort an email alphabetically in bash
I am trying to sort a list of emails in alphabetical order in bash to no avail
The emails involve numbers and periods:
[email protected]
[email protected]
[email protected]
[email protected]
k.slick20@...
1
vote
0
answers
39
views
merging with format ;string;
I repost my question hoping to provide now a minimal reproducible example
Is basically doing a merge of the two files with format NAME;URL;?
Not exactly, string is not required to be a URL, it is ...
1
vote
2
answers
857
views
Mintty terminal emulator: how to use “Image screenshot export”?
I'm programming in Bash (Git BASH) on Windows Server 2012R2.
From within my bash scripts, I would like to make a Screenshot of the mintty window, I'm running in.
According to https://mintty.github.io/ ...
1
vote
1
answer
4k
views
How to override a file via scp not being the owner, but preserve timestamp?
I have 2 users on a remote machine (let's call them user1 and user2, with both being in the common group upload).
I want to be able to upload/override a file via scp, from different machines. Whereas ...
1
vote
1
answer
233
views
"Upload" pipe as if it were a regular file
Suppose I want to tar and compress a file for upload to Google Drive or something, but all without ever saving an intermediate tarball (e.g. because of a lack of disk space and/or the disk is read-...
1
vote
0
answers
34
views
on the password prompt, the shell automatically adds a return after entering a character and displays authentication failed
logging in to an ubuntu 16.04 server via ssh. This has never happened before. The other user I asked seems unaffected by this. What could have happened? Also, when I try to enter my git credentials ...
1
vote
2
answers
7k
views
Clearing Chrome's DNS cache from the terminal
I have written a script to add websites to the hostfile at certain times of the day. For example, it can block Youtube from 8pm - 10pm. It works well, however the changes aren't reflected in Chrome. ...
1
vote
0
answers
2k
views
Why can't I execute shell script via crontab?
I have this script shell1.sh ubicate in /home/documents/files, the script is for the creation of users on Linux, so it asks for some information and later creates the user.
I want it to run for every ...
1
vote
0
answers
922
views
Loop record RTSP stream with VLC
I am able to save an RTSP stream to a .mp4 file using the following command:
/usr/bin/vlc -vvv rtsp://stream_address --sout=file/mp4:/home/test-$(date +"%Y%m%d%H%M%S").mp4 --intf dummy --...
1
vote
1
answer
360
views
Difference between [ tar cvf archive.tar * ] and [ tar cvf archive.tar . ]
Difference between tar cvf archive.tar * and tar cvf archive.tar ..
Is there any difference in the archive produced?
I couldn't find anything when I googled this.
1
vote
1
answer
150
views
"putty --display" parameter explanation
with man putty i see:
--display display-name
Specify the X display on which to open putty. (Note this option
has a double minus sign, even though none of the others do. This
...
1
vote
0
answers
23
views
Can FireFox's native `view-source:` schema for ANY text file be restored?
FireFox's native view-source: schema seems to be have been crippled.
Perversely, this would even render binary file URL's when prefaced with view-source:.
This was very convenient for quick perusal of ...
1
vote
1
answer
814
views
what does start and end refer to in the disk managment on linux
I have started learning basic IT and Disk management on Linux for a program I am writing. I started with the parted tool and when creating a disk it requires start and end values for creating ...
1
vote
2
answers
147
views
Sending param to bash from cmd
I want to be able to invoke the file command from within cmd.
This works, but is a pain to type:
bash -c "file filename.ext"
This is much easier, and works as expected...
DOSKEY file=bash -...
1
vote
3
answers
97
views
I messed up a backup script and now have File1.txt/File1.txt for a lot of files. How do I delete the directory and keep the file? OS is Ubuntu
For example, I have:
~/backup/File1.txt/File1.txt
But I want to have:
~/backup/File1.txt
The directory File1.txt is empty except for the file File1.txt. To manually solve the problem, I've moved ...
1
vote
0
answers
149
views
How to launch a subprocess with captured output, but letting the subprocess believe it isn't captured?
Imagine launching a subprocess say my_binary in these two ways (I'm using bash for simplicity, but I assume this applies for other languages on POSIX systems):
#!/bin/bash
# 1) inherit stdout/stderr
...
1
vote
0
answers
97
views
Tool written in Go works fine from terminal (in any directory) but gives "command not found" error when called from inside a script
I wrote a shell script that bundles a few networking tools together (amass, nmap etc) and they all work fine except httprobe (a tool that takes a list of domains and probes for working http and https ...
1
vote
0
answers
28
views
window batch) manipulating 'for /f "usebackq" %%f in (`find "str" path`)' sentence [duplicate]
I symplified the problem here:
@echo off
set res=
echo 'na':
for /f "usebackq" %%f in (`find "na" things.txt`) do set res=%%f
echo %res%
pause>nul
and that things.txt file ...
1
vote
1
answer
34
views
Bash PS1 dissappears after history browsing [duplicate]
I have been configuring my new fresh Arch installation. I just finished with my PS1 in Bash and realized about an error I do not know how to solve.
This is the code:
PS1='\n\[\e[30;44m \u@\h \]\[\e[34;...
1
vote
0
answers
617
views
Permission Denied While Running Script
I am attempting to run a script from the shairport-sync service with this command:
run_this_after_play_ends = "/home/pi/Watson/testmicend.sh"
/home/pi/Watson/testmicend.sh:
#!/bin/bash
...
1
vote
0
answers
4k
views
Running command-line tools giving python3 bad interpreter, no such file or directory error
I have two versions of python installed on a server: /usr/local/bin/python3 (version 3.6.3) /home/ubuntu/miniconda2/bin/python (version 2.7.15)
Earlier today I removed python version 3.6.3 and 3.4.0 ...
1
vote
0
answers
264
views
Xubuntu GUI not loading?
I just installed xubuntu-core on my amazon-ec2 server, but I can't get it to load into a UI. When I try to use sudo startx it throws an error, while sudo service lightdm start doesn't seem to do ...
1
vote
1
answer
505
views
Setting Environment variable for bash/zsh completion
I am using gnu pass with bash/zsh completion. This means when I type pass a[TAB] the shell suggests which passwords I have available starting with a.
I have two gnu-pass directories, when I want to ...
1
vote
0
answers
270
views
Ubuntu WSL installation error
I'm trying to install the Ubuntu 18.04 WSL on Windows 10. Download (manual) seemed to go fine, and when I did Add-AppxPackage in Powershell I didn't get an error message. But when I try to do the ...