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

learn more… | top users | synonyms

0
votes
1answer
59 views

How to configure linux to display webpage at localhost 127.0.0.1 that allows javascript-issued terminal commands?

Sorry if I am confusing things (don't know much about this topic). Basically, I want to access my raspberry pi wirelessly from my phone as long as I am within a few meters of it, and in this situation ...
0
votes
4answers
55 views

Please explain the man page of command mv

I understand if I mv foo.file boo.file, I just rename foo.file to boo.file, and if I mv dir1/foo.file dir2/boo.file, I delete dir1/foo.file and make a copy of that to dir2 and rename it as boo.file. ...
1
vote
1answer
35 views

Removing illegal characters with Automator

I've been trying to write a Mac Automator service to remove illegal characters from filenames. I have it working, but the solution is a little inelegant and I was wondering if anyone would have a ...
0
votes
0answers
25 views

How can I automatically run two commands in different screen windows with an argument?

My process is ctrl+a 0 command $1 ctrl+a 1 /join#$1 I'd like to shorten it down to one command.
-1
votes
1answer
23 views

Find specific file with a for loop

I have a list of files in multiple directories. I would like to work on specific files but the naming is a little tricky. file_986.aln file_99.aa.aln file_99.aln file_991.aa.aln file_991.aln I ...
1
vote
0answers
16 views

Grep from Log & Calculate then alert

I have a log file, which has the below lines in it. I need a bash script, which takes the values in Bold (4092.1M / 20.1G) & do the math & then alert from Zabbix [Eden: ...
0
votes
1answer
50 views

bash: adding a common string to files found with wildcards

I'm wondering if there is a way to rename a wide range of files that are found using wildcard patterns. For example, say I want to scp all files that match a certain pattern, but append a string to ...
0
votes
1answer
141 views

Require bash script to be run with sudo (not as root user)?

I want to require a bash script to be run as the current user with sudo, but prevent it from being run if it was executed as the root user directly. This is because I'm doing some setup actions for ...
1
vote
1answer
32 views

BASH - run commands before and after loop

I'm having a bit of trouble with a shell script. It's something so stupid I'm almost ashamed to ask, but I can't figure it out. This is the script: #!/bin/bash MAGAZINE=" 192.168.49.3 ...
0
votes
0answers
8 views

Bash/Cygwin synchronize two directories

I have small problem with synchronization of two git repositories. In first directory for example localRepo is only two subdirectories: localRepo/ dirA/ dirA1/ ...
3
votes
2answers
85 views

Loop in a script until file exists

I'm trying to have a script find a file in /tmp called sleep.txt but instead it keeps looping Here's what I have: #!/bin/sh set -x until [ $(ls -la | grep -w "sleep.txt" | wc -l) != 0 ]; do ...
0
votes
1answer
65 views

Unix Script: Wait until a file exists

I need a script that will wait for a (examplefile.txt) to appear in the /tmp directory and once it's found to stop the program, otherwise to sleep the file until it's located So far I have: if [ ! ...
0
votes
1answer
40 views

Piping grep causes error $'\302\240grep': command not found on linux

Sometimes when I'm catting & grepping a file, I see this error come up: $ cat something.txt | grep "some text" -bash: $'\302\240grep': command not found When I re-type the command, it works as ...
0
votes
1answer
40 views

Programs for contolling the execution of bash scripts [closed]

Can anyone recommend a GUI based program to control the execution of bash scripts according to time/interval? I'm already familiar with both cron and at and looking for recommended alternatives. A ...
2
votes
1answer
53 views

strange if statement behavior on linux

I am writing a shell script and have come across some weird if behavior. My question is simple, why does [[ "╝" = [█] ]] evaluate to true? Is it because they are both uncommon ascii characters? On ...
0
votes
0answers
21 views

`newgrp` breaks source-ability of shell script

This is my minicom.sh, which I can source successfully with source minicom.sh: minicom --device /dev/ttyUSB0 --baudrate 115200 --color=on However, when I change the content of minicom.sh to this, ...
1
vote
1answer
15 views

Inconsistencies with which command

I'm using the n tool to update my current version of node, but something strange is happening. I ran sudo n latest which in theory fetches the latest version of Node (v0.12.0 and installs it ...
2
votes
1answer
52 views

How to start terminal in which bash is running with adjusted environment variables?

I'm using Xubuntu with XFCE. I would like to write a bash script which opens a new tab in the xfce4-terminal. In this tab, the bash should be running with an altered PATH environment variable. ...
1
vote
1answer
63 views

Is there a way to enable minicom linewrap by default

I use minicom when working on router terminals... by default, I use these settings in my ~/.minirc.dfl: pu port /dev/ttyUSB0 pu baudrate 9600 pu bits 8 pu parity ...
0
votes
0answers
37 views

Proper way to execute a script before running upstart based service?

I run the deluge torrent client within a virtual machine that mounts an NFS share from the filer that runs bare metal. Occasionally deluge starts before NFS has been mounted, and it starts downloading ...
0
votes
1answer
20 views

ssh | how to handle errors for multiple commands

Hi I am aware that we can check the status of previous command by $? following scenario is not working for me ssh $USER@$HOST bash -c "' echo "Preparing list of files to be transferred...." rsync ...
0
votes
1answer
53 views

Bash Scrolling Output Cygwin

My apologies if this has been asked before but I did my best to find it beforehand. I have a bash script like so: #!/bin/sh <Appropriate variables here> lftp -c "open -p $port -u $login,$pass ...
0
votes
1answer
38 views

BASH associative array rearrange keys

I am running into a weird issue with associative arrays in bash. I have the following files in a directory: ls -lart drwxr-xr-x. 3 root root 4096 Feb 9 11:14 .. -rw-r--r-- 1 root root 3275 Feb 9 ...
0
votes
0answers
29 views

Open two URLs in a new Firefox window OS X

I am trying to launch Firefox from a bash script. The desired result is that a new window will spawn with two tabs that load two specific urls. I have successfully done this with Chrome as follows: ...
1
vote
1answer
80 views

Exit bash script when curl gets a non 200 HTTP status

I have a bash script setup to perform a few curl requests for currency in EUR INR JPY do curl -i --data '{"currency": "'$currency'"}' -H "Accept: application/json" -H "Content-Type: ...
0
votes
1answer
25 views

linux command executed from a different path than whereis

I installed paris-traceroute and I don't remember what I did to replace the ping packaged with Ubuntu Trusty with paris-ping, which requires root to run. Now I want to get rid of it. $ ping --version ...
1
vote
1answer
90 views

file exists not working in expect script

I'm trying to check if a particular line exists in filename on a host. So only if the particular pattern is found from the grep command a dummy.txt will be created. Then I want to check if dummy.txt ...
0
votes
0answers
27 views

Linux: how to convert multi-mp3-audiobooks with appropriate cuesheets?

I have several audiobooks in MP3 format, which are in multi-file format which means, they are named like CD01_CHAPTER_001.MP3 and so on. Now what I would like to do is the following: convert the ...
1
vote
2answers
25 views

Not creating new file while output redirection

I'm using this for output redirection: cat filename | grep 'dis' | wc -l > test.txt But I do not want a zero byte file created if no result is found from the grep command. Is there any way this ...
0
votes
0answers
13 views

Match the end of a path using bash completion

I am trying to modify z.sh so bash completion will give me a list of matches when the pattern occurs anywhere in match. I think I am bumping into a limitation on bash's completion tools. Here is a ...
0
votes
0answers
39 views

Sorting HTML content based on second line of table cell

I have an Windows text file, containing the text of an HTML table (no header, no footer) with each cell of the table not in alpha order. I'd like to alphabetize the tables, a la: REDACTED-TITLE-1 ...
0
votes
1answer
32 views

Why doesn't my script run via crontab?

I have this teamspeak server that has a bad habit of crashing sometimes. Therefore I would like to run a script every 5 minute so the server can restart even if I'm not home. I got this script, and ...
0
votes
2answers
26 views

Is cat output modified by writing to the file

With a piped command sequence like: $ cat afile | somecommand | tee afile afile is both read (by cat) and written (by tee). The question is, supposing afile is at least several megabytes (or large ...
1
vote
1answer
20 views

How can I get the unique items in a bash array?

If I have this array arra[0]='Debian' arra[1]='Debian' arra[2]='Ubuntu' arra[3]='Suse' How can I stock in a new array Debian, Ubuntu and Suse only ? like this new[0]='Debian' new[1]='Ubuntu' ...
0
votes
1answer
35 views

bash: find and zip all subfolders of a folder

how would one find all subfolders of a folder and zip them separately ? folder structure ./folder -subfolder_1 -subfolder_2 -subfolder_3 expected result: ./folder ...
0
votes
1answer
64 views

integer expression expected error when trying to run a command on each line

I am trying to essentially run a command on each line of a file. Below is what I have so far. I want to be able to take each line, take the last column from it, run a command on the integer and if it ...
0
votes
2answers
29 views

Thunar custom command: Keep Terminal open

When I make custom commands for Thunar with the xfce4-terminal -x command, sometimes I'd like to see the Terminal output of the command. How can I prevent Terminal from closing after the command is ...
1
vote
1answer
37 views

Linux: Get CPU usage over past n minutes

I want a script to tell me the average CPU usage over the past 5 minutes (and repeat every 5 minutes, likely as a cron job). /proc/stat just has counters since system start, and I want to avoid ...
0
votes
1answer
12 views

How can I use each line like an argument in text output?

I've got a file with text like a 111 222 333 444 555 I want that each line was an argument for text block: Input=file.name Hello world $Input Output: Hello world 111 Hello world 222 Hello world 333 ...
0
votes
1answer
32 views

Custom bash 'context' when running from FISH

First of all, I'm on OSX10. My default shell is BASH, which I have set up (through .profile and .bashrc) to automatically run the FISH shell when I open my terminal emulator. This allows me to set up ...
1
vote
1answer
42 views

In Linux, what would be the best way to recursively ZIP multiple directories at once? [duplicate]

I have a directory, /dir, and it is full of other directories with no common naming scheme. So /dir/EqcWTG /dir/SomeDirectoryName /dir/3435346 and so forth. I would like to turn each one of these ...
0
votes
1answer
123 views

SSH into Homestead Using Git Bash on Windows Characters Not Displayed Properly

After running: homestead ssh and logging into the VM everything looks okay until you're typing certain commands or viewing command results where the characters aren't rendered properly so you get ...
0
votes
1answer
29 views

Which is the preferred approach to pass command/script arguments to a log file?

Generally, I am wondering how I can pass the arguments from a terminal command to stdout. More specifically, I am using tar as part of my backup process and I would like the parameters (especially ...
0
votes
1answer
37 views

lubuntu: alias application-specific initialization failed: file open failed

I'm using lubuntu(ubuntu) and have a problem with the alias function when I want to open xampp. When I type sudo /opt/lampp/manager-linux-x64.run it works fine. When I create an alias with: ...
2
votes
1answer
81 views

How to time multiple commands including 'cd'?

Suppose I have multiple commands on one line including 'cd', for example: cd subdir; pwd Now I want to keep the behavior of this script the same, but time the line. If I do this: time bash -c 'cd ...
0
votes
0answers
15 views

Timestamp bash_history of a different user in a filesystem

I have a partition .dd file with the bash_history. I am able to cat it and look at the bash history and I know that the HISTTIMEFORMAT="%d/%m/%y %T " is typically used for the timestamp of the current ...
0
votes
0answers
13 views

Bash variable READLINE_LINE always empty

I was looking for a way to share clipboard between bash and X, but the variable $READLINE_LINE and $READLINE_POINT is always empty. Does anyone know the reason? Bash version is 4.3.30. See the post ...
1
vote
1answer
165 views

ssh + sudo + su into login shell

I have several machines I ssh into regularly only for the purpose of using sudo su to spend the rest of my session logged in as some special-purpose user. The general workflow is: mymachine:~ me$ ssh ...
1
vote
1answer
112 views

oh-my-zsh (terminal) how to change prefix & suffix of new prompt window

Installed on my Mac running Yosemite is a few packages to make life in the terminal (iTerm 2) a bit better. I have oh-my-zsh (only plugin I have id antigen for oh-my-zsh) along with oh-my-git ...
12
votes
2answers
440 views

Difference when using backticks in double quotes and single quotes in Bash

Why to the following two executions differ in output? (I need double quotes for variables in my eventual command) $ sudo su -c "echo `cat /root/root_file`" cat: /root/root_file: Permission denied $ ...