Tagged Questions

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

learn more… | top users | synonyms

1
vote
1answer
6 views

Possible to get a bash script to accept input from terminal if its stdin has been redirected?

Say I've got a bash script: #!/bin/bash read -p "Gimme some stuff: " stuff echo "**${stuff}**" If the script is invoked with something piping into it, such as: echo "Here's some stuff" | ...
0
votes
2answers
19 views

ascii value in bash/awk

i have a doubt, i know that with this command, it prints the value of a character based on the Ascii table: printf "%d\n" "'a" ##prints 97 But i wonder how can i make my programm show me the ascii ...
0
votes
1answer
8 views

what should i worry about when using mktemp --dry-run

I've been trying to make a temporary named fifo and after referencing Bash: create anonymous fifo I see they are using mktemp -u to get the file name for the fifo. The man page states this is unsafe. ...
1
vote
1answer
6 views

Homebrew script to reinstall formulas

I'd like to develop a bash script to capture the currently installed Homebrew formula, then be able to reinstall these formulas in the event that I need to reinstall my OS. I'm hoping to combine ...
1
vote
1answer
9 views

Using grep, sed or awk to find words in between? I want to be able to extract the package name until .el7

I am writing a script (bash/command-line) and I want to be able to extract the package name until .el7 x=dbus-sharp (an example package name - which changes) example text file: Building ...
1
vote
2answers
19 views

How to kill a continuous process started from rc.local?

I'm working on a Raspberry Pi with Raspbian (Debian-based) OS. For testing I added such a command in /etc/rc.local: python /home/pi/test.py It works fine starting this script. But the problem is ...
0
votes
1answer
10 views

Getting xargs: unterminated quote when trying to find text in files

I'm using Mac 10.9.5 with bash shell. I'm trying to search for instances of text within a group of files, but for some reason, in one particular directory, I get this bizarre "Unterminated quote" ...
0
votes
2answers
40 views

Why do I add a path to ~/.bash_profile and source it, but there's no effect?

In my install.sh: # other commands to install java... echo 'export JAVA_HOME="/usr/java/latest"' >> ~/.bash_profile source ~/.bash_profile After this script runs, I type echo $JAVA_HOME, but ...
0
votes
1answer
24 views

Where do the variables of a new BASH shell come from?

I am puzzled as about how environment variables work. From what I am aware, for a new process to have some environment variables, its parent must have issued export. But what about all the variables ...
2
votes
1answer
21 views

What are the rsync equivalent command/s to mv /a/b /c/d?

What are the rsync equivalent command/s to mv /a/b/ /c/d/, i.e, to move a directory tree from one location to another, possibly on another file system? That is, not just copy, but delete the files ...
0
votes
0answers
11 views

How to force wget to output a summary?

I have a bash script that launches a series of wget commands, and log the output. I use the following options: wget --no-verbose --page-requisites --adjust-extension --convert-links ...
0
votes
0answers
33 views

I accidentally deleted files of root folder

Now my root folder is looking empty.And I lost my shell string (same as: I accidentally deleted my /root folder and now my shell string is different. What gives?) What should I do now ? I created ...
2
votes
1answer
19 views

Unset bash variables referring to non-existent directories

I have a file which is sourced by an application, adding relevant directories to $PATH and $LD_LIBRARY_PATH. This is fine, but it results in somewhat excessive pollution of the $PATH and ...
0
votes
2answers
29 views

How to check if busybox has a command?

In my case, I want to see if busybox has "md5sum" builtin. I am currently doing this: $ echo | busybox md5sum &>/dev/null && echo yes || echo no I have not been able to find any ...
0
votes
1answer
27 views

What could cause HostName in command line to display differently?

I am on OSX, and my host name in the preferences panel reads "User's Computer Name" but when I go to my command line it is reading: something else:~ myusername$ My understanding is the first part of ...
1
vote
2answers
20 views

Get SSH one-liner commands to show color

I'd like to enable colored text output on SSH one-liner commands, but I can't seem to get it to work on OS X, Ubuntu 14.10, or OpenSUSE 12.2. If I ssh into a server and type, say, ls --color=auto in ...
0
votes
1answer
8 views

Release control from init.d script centos

I am using logstash-forwarder and starting it inside its init script with the command: /opt/logstash-forwarder/bin/logstash-forwarder -config=/etc/logstash-forwarder -spool-size 100 This command ...
0
votes
1answer
18 views

Prompt yes or no to repeat a command in a bash script

I've attempted using "while" and "ask" without success but the whole goal of this script is to run a command or commands and then ask if you want to repeat the command again. Example: echo "adding a ...
0
votes
1answer
9 views

Centos How to give permission to view folder ?

I push all the local files to Google Compute Engine using gcloud compute copy-files then login to VM using gcloud compute --project and view the uploaded file using ls command it's there .. No ...
2
votes
2answers
41 views

Warning for rm -r command

I want rm to prompt me when recursively deleting a directory, as in: $ rm -r <dir> Do you want to remove the dir(Y/N)? Is there an argument I can pass to rm that will do this?
0
votes
3answers
43 views

remove rm command not working with wildcards on Mac OS X

I am trying to remove the below file for all user accounts through a bash script but the wildcard * does not seem to work. I have been testing the script locally by running it on mac os x terminal. ...
1
vote
1answer
16 views

Display the PID with bash scripting

Good day all, I am trying to write a bash script to show all processes of java, however i would like it to display in the below manner. ps -p $PID -o pid,vsz=MEMORY -o user,group=GROUP -o ...
1
vote
1answer
20 views

Evaluating false in bash with multiple commands without a subshell

Bash evaluates the logical operators such that && always takes precedence. So for example: false || echo 1 && echo 2 1 2 and true || echo 1 && echo 2 2 Ok. So lets say I ...
0
votes
2answers
18 views

Can gnu diff recursively compare only filenames in different folder structures?

I know that I can recursively compare two dirs with diff -qr and output only the differences. However, this appears to compare file positions within the trees (for example, /a/b/file01 != ...
0
votes
2answers
31 views

Executing Commands In Parallel That Never Finish

I'm attempting to run a few commands that never finish. These commands watch a directory and update files when they change. The idea is that I need multiple folders watched by different tools, able ...
0
votes
1answer
14 views

How to get bash history of already running session?

How to get bash history of already running session? 1.) I was thrown out of my server because of a cable fault. 2.) I logged in again using a new session. History of the other session is not ...
1
vote
2answers
19 views

Split multiple gz compressed files into even more files

I have a directory full of gz files. I need to split them into smaller ones, e.g. 1M of size. I do e.g. for one file: $ split --bytes=1m one_unzipped_file prefix_ but how to achieve for many ...
0
votes
1answer
48 views

Bash script that calls a program with some asterisks in arguments

I’ve spent last hour or so trying to write a pretty simple bash script and I never felt so dumb. So I have a list of strings (which are package selector specifications for a package manager, if that ...
1
vote
3answers
33 views

Copying multiple files on linux

I have a linux machine with folders named numerically. How can I securely copy ranges of these folders to another server? The source machine runs tcsh, the target bash. At the moment, from the ...
1
vote
1answer
28 views

Using the mv command with multiple wild cards

I'm still relatively new to Linux, so take it easy on a noob, eh? I have scripts set up to move media files to a specific directory based on its name. I used a wildcard to accomplish this, but I need ...
2
votes
2answers
27 views

Look around bash command history match

I got a match for Ctrl+R In bash. How do I go back and forth around that position? I have several commands that are run in sequence but I forget some of the commands names. Thank you!
-1
votes
0answers
24 views

what's the difference between export and env_export?

What's the difference between export variable=value and env_export variable value?
0
votes
1answer
25 views

Passing different set of arguments to the different commands in a linux bash script

I am writing a bash script foo.sh that runs too commands bar with first input argument, and baz with the second argument: #! /bin/bash bar "$1" baz "$2" Now I want to make foo.sh more flexible, ...
1
vote
5answers
82 views

How to copy hidden (starting with a dot) files and subdirectories in linux?

How to copy hidden files and hidden subdirectories (the ones starting with a dot) in folder A to folder B? For example if I have this structure: A/a A/b A/.a A/.b/ A/.b/somefile A/.b/.c I would ...
0
votes
2answers
25 views

Update a sqlite database while select into a while loop

There is a bash script that will do "some magic"™ to files which will be referenced to a sqlite database and after doing "some magic"™ the database should be updated. Here are the simplified code ...
0
votes
2answers
40 views

sudo cp with wildcard syntax doesn't do anything in Linux

I have a directory containing files that are owned by root, from this directory I wish to copy all the files ending with errorAll to another directory. My wildcard syntax is correct because performing ...
0
votes
1answer
15 views

Keep screen running after starting it with an alias and running some commands

I have a bash alias to move into a project folder, start screen, and pull new changes from git. it looks like this: alias start_manager2='cd ~/programming/manager2/ && screen -t "main" ...
1
vote
1answer
37 views

How to use linux bash “sort” command in a portable script?

I am writing a bash script and I want to make it portable, to have the same results in the other computers. From this question I learned the system settings, like language settings and possibly other ...
0
votes
1answer
27 views

Unexpected result from sort command of linux bash

I have a file foo.txt with this content: chr1 15 chr11 5 chr11 8 chr1 7 chr2 23 chr1 35 I tried to sort it first according to the first column, and then according to the second ...
-1
votes
1answer
32 views

find all IDs and CLASSes used in an HTML document in BASH

I have a block of HTML that I need to pull all the IDs and CLASSes out of. Im wanting to make a list of these so that I can start trimming our larger then necessary CSS doc (173k). Ill isolate the ...
3
votes
2answers
47 views

How do you CD change directory into the absolute path of a symbolic linked directory?

I'm currently in a symbolic link directory and I want to go up one level in the absolute path, but I cant as it will hit me back up to my home directory (~). I can do pwd -P to get the absolute path, ...
0
votes
2answers
26 views

RPM command stuck/FREEZE when installing RPM file

I want to install the following rpm from some reason RPM is stuck or freeze and not install the RPM package also I cant stop it by control C , please advice what could be the problem ? root]# rpm ...
3
votes
1answer
15 views

In bash, declare an alias that depends on current variable content

I would like to declare an alias in my .bash_profile that will use the content of a variable when the alias is used and not when it is declared. Ex: alias goSomeWhere="cd $BASE/somewhere" When ...
0
votes
1answer
28 views

Delete All files except specific file in bash [duplicate]

I am trying to use rm -rf !(current) delete all folders in current path except current folder. But I am getting below error bash: !: event not found How do I get this functionality in bash?
1
vote
1answer
31 views

Windows batch equivalent of bash's set -e

Is there a Windows batch equivalent to bash's set -e, which causes the shell to exit immediately if a command fails with nonzero exit status (except in places where it's expected like in an if ...
0
votes
1answer
21 views

Kill browser tabs with Bash from younger to older

Hello i want to kill tabs from a browser(ex. chromium) by order from youngest to oldest. I used pkill -f -n -9 chromium but i want to use it in a while iteration with comparison to pkill's return ...
1
vote
2answers
54 views

What does ./ mean in Unix/Linux [duplicate]

This might look wrong, but I know that using ./ you are basically "BASH"ing your scripts in Linux/Unix environment. For Windows users, this is same as running an .exe file from command prompt. ...
0
votes
1answer
35 views

remove spurious ending spaces when copy pasting from emacs console mode?

I'm not really sure where this comes from but it's really annoying: Using emacs in console mode, and when I want to copy from emacs and paste to another application (possibily another term) I often ...
0
votes
0answers
21 views

How is a basic daemon made on OSX?

I have an OSX system that I'd love to have some daemons set up on that will automate the updating of all of my console utilities. How would I go about creating and running such daemons? I'd also like ...
0
votes
1answer
18 views

Delete a file inside multiple ZIP archives on the OS X command line

I'm trying to delete files with specific extensions from multiple zip archives. For example I want to delete all .html files contained in the zip archives in the current path so I have tried this: ...