Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

Questions tagged [shell]

A shell is software that lets users interact with the operating system, usually by typing at a command-line.

0
votes
0answers
5 views

How to zip log in Centos 6.5 [on hold]

Now my server is storing log as files: server.log.2018-08-19-09, same form: server.log.yyyy-mm-dd-hh. I want zip log for day, sample server.log.2018-08-19.zip or .tar.gz .... to other folder and ...
0
votes
2answers
39 views

Automatize multi-hop SSH and SCP with passwords

I want to access some host from my personal computer, but I have to access an intermediate server first, because the final destination cannot be seen from public internet. The thing is that I have to ...
1
vote
0answers
20 views

Detach a terminal from a process in D (uninterruptible sleep) state

I have a shell command in stuck in D state (imagine doing ls on a NFS share when the network is down). How do I detach from such a command? I can't kill the process in any way (well, it's called "...
0
votes
1answer
14 views

Bash script for Docker container in Windows returns “Unknown target”

I've downloaded a repository that contains a .sh script to open a Docker container. I'm running Windows 10 with Docker Toolbox (rather than the full version, which has some Hyper-V issues) and its ...
1
vote
1answer
20 views

Shell script: run screen, open several screens and run a command in each

Pretty much what the title says: My shell script should Run command A, wait until done run "screen" run command B1 in initial screen open new window (usually via Cmd-a-c) run command B2 in new ...
0
votes
0answers
9 views

How to allow bundler sudo permissions?

1.How to allow bundler installing with sudo? In other words how to use "bundle install" without given error: Bundler::SudoNotPermittedError: Bundler requires sudo access to install at the moment. Try ...
0
votes
0answers
9 views

Is there a way to run adb as host on android without root? [migrated]

I have an android phone and an android tablet. Both not rooted. I want to use adb as host on the tablet and as client on the phone, using an USB-OTG adapter. I downloaded connectbot as terminal ...
0
votes
2answers
28 views

Preview current directory in shell

What often happens when I work in a shell - zsh - is that I have cded somewhere and I want to have a quick look at the directory. Using ls may produce a lot of output and leaves it in the terminal. ...
1
vote
1answer
61 views

What does --) mean in bash's case struture?

I have seen a code snippet containing a case structure. while true; do case "$1" in --prepare) echo "prepare" ENV_PREPARE exit 0 ;; ...
0
votes
1answer
50 views

How to write -exec command with different format

Someone gave this script for log rotation. I want to know what is logic behind it. Though I understand all except --exec which was little confusing for me. original Script: #!/bin/bash set -x NOW=...
0
votes
0answers
131 views

How does one add shell parameters while executing commands with su?

The situation. I am debugging the environment of a restricted user who is relagated to a special shell. In order to do this, I need to run a command as that user in their full context using su like ...
0
votes
1answer
25 views

if -else in shell script, matching argument with string

For the following shell script - #!/bin/sh main_version=0 feature_version=0 patch_version=0 if [[ $1 -eq "m" ]]; then main_version=$((main_version+1)) fi if [[ $1 -eq "f" ]]; then ...
0
votes
1answer
11 views

How to use variable in variable in bash?

I have two variables - regex="<version>[0-9]*\.[0-9]*\.[0-9]*[^<]*<\/version>" updated_regex="<version>${main_version}\.${feature_version}\.${patch_version}${tag}<\/version&...
0
votes
0answers
24 views

Regex matching in shell script

Here is a snippet from my shell script - regex="<version>([0-9]*)\.([0-9]*)\.([0-9]*)([^<]*)<\/version>.*" #some unrelated lines of code echo $(grep -m 1 "<version>" $1) ...
0
votes
1answer
35 views

How to remove all files from folders?

I'm getting a list of folders with command locate my_folder How i can empty/delete all files from those folders?
0
votes
0answers
39 views

How to run a batch or exe file when clicking to enter a drive or execute itself in windows

Although a batch file with executable commands could be run in different ways, I wonder if there is a way like making "autorun.Inf", which is disabled in windows,to run that "bat" or it's "exe" file ...
1
vote
1answer
40 views

What is a “shell:” in windows

Use "shell:sendto", I can open this folder C:\Users\myName\AppData\Roaming\Microsoft\Windows\SendTo Use "shell:startup", I can open this folder C:\Users\myName\AppData\Roaming\Microsoft\Windows\...
0
votes
1answer
27 views

How to output a particular word in file, if it is present?

I am making a simple script where i turn true to false if true is present in file or vice versa if false is present in file, details here. Now i want to output, what is the value after change ie if i ...
0
votes
1answer
124 views

How to check what is the default shell

Is there a config file that stores the default shell (bash, zsh, etc) for the current user ?
0
votes
1answer
24 views

How to limit a log-file to last N lines?

I have a ./program which outputs lots of logging messages and also having very limited storage space on my VPS: I would like my log-file to contain only the latest N lines all the time (or rather ...
3
votes
3answers
44 views

Combine multiple lines dynamically in unix

I have below scenario: Iteration 1 - Ddd Bbb Ccc Ddd Eee Fff Ddd Iteration 2 - Ddd Bbb Ddd I want to combine the data as below - Iteration 1 output - Ddd Bbb Ccc Ddd Eee Fff Ddd Iteration 2 ...
1
vote
1answer
18 views

Extract Text from a file in Shell

I wish to extract the text between the pattern that starts with first occurrences of "SCRIPT:main, SIB:orvault/inap/si8/begin," and ends with first occurrences "---------------------------------------...
1
vote
1answer
45 views

urban legend : why is it better to avoid using file descriptor 5?

In the answer to this question, the answerer quoted a block of scripts, which contains a line like this exec 4>/path/to/output.file #and a third, for reading and writing, with FD 6 (it's not ...
0
votes
0answers
337 views

Cannot run lxterminal from LXsession autostart

I'm trying to run a script right after my Raspberry pi's X server is on, because it runs with a GUI. After a lot of search, I found out that I could make a script run in the following file ....
0
votes
1answer
78 views

see Unix userids in macOS

I have a million-file 900-userid snapshot of an old Unix file server. On Linux I can browse it and have ls -l show usernames from the snapshot's /etc/passwd, by just chroot'ing to the snapshot's top ...
0
votes
1answer
55 views

Why don't Go (lang) binaries show up in `which`, `whereis`, and similar tools?

I've installed a couple of Go utilities via go get -u github.com/[owner]/[repo] and I don't understand why they don't honor standard shell conventions. The utility I installed had no trace of anything ...
11
votes
2answers
2k views

How to edit Excel file (xlsx) using linux shell

Is there a way (tool) to edit XLSX files using Linux shell? What I need is a way to remove the last three not empty rows from the first worksheet. I know that XLSX is just a zip file, packed with ...
1
vote
1answer
27 views

Difficulty importing numpy into python shell after installation

After installing numpy through pip in my command prompt then entering a python shell, I can't import numpy into the shell for use. I've uploaded a picture for reference; I have tried restarting my ...
0
votes
1answer
18 views

shell command on matching line (in vim: combine the global `:g` or `:v` command with shell command)

I want to use a shell command (fmt in this case) to operate on every (non-)matching line of a regex in a file. I'd prefer to do it within vim! I am, nonetheless, open for a pure shell/bash/zsh ...
0
votes
2answers
36 views

Vagrant: Shell Provisioner operation in a multi-machine environment

I am building a multi-machine environment and am puzzling over the behaviour I am seeing as the Vagrantfile is processed. My goal: Create n number of virtual machines with 3 different roles. All n ...
2
votes
1answer
30 views

Shell pipes - the order of things

Because netcat on my box doesn't support -e, The netcat man page gives me this workaround: $ rm -f /tmp/f; mkfifo /tmp/f $ cat /tmp/f | /bin/sh -i 2>&1 | nc -l 127.0.0.1 1234 > /tmp/f I ...
0
votes
1answer
97 views

How should I install homebrew into /usr/local subdirectory manually?

Manual installation directions in docs.brew.sh are very brief and unsatisfactory, resulting in some errors if I try it in a subdirectory of /usr/local without using sudo. Directions in this question ...
1
vote
1answer
52 views

Forward shell to serial on Linux

I'm trying to forward a shell to serial (USB to RS232) so I can use an old monochrome CRT terminal. How can I forward a shell to a serial port so the other end can send commands & read output ...
0
votes
0answers
28 views

Launching a UWP app as the shell

In the excellent answer to How do I replace the system shell (explorer.exe) with another process in Windows 10? one provides the path to an executable as the value of a registry key. Can this be ...
1
vote
2answers
88 views

Get intermediate nodes using ping

I need to get intermediate nodes when requesting the route through ping. I can get the intermediate routes through traceroute url, but in the server there's a problem I cannot use traceroute. I ...
1
vote
1answer
19 views

Handle filename with blank in shellscript

These are my folder structure. [set symbolic links here] /links/ [entity] /data/a 1/ #(folder name has blank) /data/b 1/ /data/c 1/ /data/d 1/ . . . I want to made symbolic link for each ...
3
votes
1answer
28 views

Filename generation from variable in zsh without spawning subshell

In zsh I have a glob pattern in a variable, and I want to define another variable that performs filename generation on that pattern. Is there a way to do this without spawning a subshell? The ...
0
votes
0answers
44 views

How to wait until services are ready

I have been setting up a Jenkins pipeline using docker images. Now I need to run various services like MySQL, Redis, Memcache, Beanstalkd and Elasticsearch. To wait the job until MySQL is ready, I am ...
1
vote
0answers
37 views

Deleting a Plist Dictionary Item by Title Key from Shell Script

I'm trying to create a shell script that will delete a top-level folder from Safari Bookmarks using Safari's Bookmarks.plist file by folder name. Unfortunately the only method I've found to delete the ...
0
votes
2answers
45 views

Simple Batch Script for Copying file to locations based on username

I was wondering if someone can assist with this script, i have tried replacing the xcopy line with echo %frompath% and it just echos nothing, its as if the scope is not correct however i am unsure, ...
2
votes
0answers
19 views

How does server 2016 core know it has to start cmd.exe as shell?

Does anyone know how Server Core knows it has to start cmd.exe as shell? It being just another version of Windows, you would expect it to be specified the same way as it always has from NT on, via ...
0
votes
0answers
26 views

Fully disable bracketed paste

Quite often I will paste something and the beginning and end will be missing. I learned that this is an issue with bracketed paste mode and I added an alias that does: printf "\e[?2004l"' This ...
0
votes
1answer
65 views

can't increment a variable inside a loop in a bash script

I am running a bash script in Ubuntu 18.04. The script needs to run a python script 10 times. I did the following testbash.sh script: #!/bin/sh count=1 while [ $count -le 9 ] do python /home/e/...
1
vote
1answer
21 views

Bash finding old version of executable in /usr/bin after installing into /usr/local/bin, why?

I installed a new executable into /usr/local/bin and this directory is in my path ahead of /usr/bin . But, bash still prefers the version in /usr/bin until I start a new bash process. The which ...
0
votes
1answer
59 views

How can I copy(or move) and rename multiple files from different directories using the unix cp command?

Let's say, under this directory: /home/data/ There are 100 folders, the name of these folders are 24538_7#1, 24538_7#2, 24538_7#3 ... to 24538_7#384. In each folder, there are many files and ...
2
votes
1answer
91 views

How to stop tmux from launching login shells?

TMUX defaults to launching shells as login shells. I am looking for a way to negate this behavior (so that it will launch non-login shells) in .tmux.conf file. Currently I can use tmux set-option -g ...
1
vote
2answers
30 views

How to create same file in all subdirectories?

I have many existing subdirectories, like: /path/to/my/subs/a /path/to/my/subs/b /path/to/my/subs/c No I want to create a new file in each of them. The filename is constant, like: /path/to/my/subs/...
0
votes
1answer
83 views

how to open tcp connection in fish shell

I am looking for a way to open TCP connections in fish shell. In bash, I can do the following to open a TCP connection. This is quick telnet type test when telnet is not installed. $ echo > /dev/...
0
votes
1answer
38 views

Bash: Copy a list of files that contain (lots of) special characters

I'm well aware of how to simply copy a list of files to another location using bash, but the problem is that my list of files contains filenames that contain just about EVERY character that needs to ...
0
votes
2answers
70 views

How to use nc to listen on a TCP port indefinitely?

I want to read the data arriving on a specific TCP port indefinitely and dump the data into a file. I have tried many different variations of nc but it is not working out for me. For the most part I ...