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

learn more… | top users | synonyms

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
34 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
28 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
73 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
83 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
24 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
34 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
26 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
36 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
41 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
117 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
32 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
14 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
141 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
98 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
436 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 $ ...
1
vote
1answer
50 views

How to delete duplicate files of two folders?

I'm just getting to grips with the Linux Terminal but I still make mistakes: I recently erroneously managed to copy all of the files contained within a directory (including all sub-directories) into ...
0
votes
0answers
9 views

Changing Git Location on Mac OS X

I have a version of Git (1.9.3) already installed on my computer at /usr/bin. This version was installed (if I remember correctly) by XCode. I would like to install 2.2.1 (the download version from ...
0
votes
1answer
32 views

Prompt for values until press ENTER key with empty value

I'm working in a bash script for automatize some tasks. This is what I have done until now: #!/usr/bin/env bash PS3='Please enter your choice: ' options=("Create new group" "Add users to group" ...
1
vote
2answers
45 views

bash complete: list directory names from a defined directory?

I need the directory names in /mailman/lists to tab-complete as an argument (without any slashes) to the 'list_members' command regardless of where I am in the filesystem. In tcsh (on our old ...
0
votes
2answers
31 views

How to find files created between hh:mm and HH:MM for any day?

For instance, find all files created between 20:00 and 23:30 for any day (not a specific day)? been going through man find and didn't see anything that would do this. Would I have to write my own ...
7
votes
3answers
236 views

Why can't I kill this process on Linux?

Problem I would like to kill a process called raspivid (program which records videos using a Raspberry Pi Camera) but I cannot... This is how I call it: #!/bin/bash #Start recording... raspivid -w ...
0
votes
1answer
34 views

Can I automatically run commands after Linux Mint Installation?

That's what I want: I want to run a bash file (composed mostly by apt-get's and instructions to download and install .deb files) just after, or during, Linux Mint installation. I've found many ...
1
vote
2answers
73 views

Bash: can't type 'e' or I'll get infinitely repeating 'H's

At my workplace, there are several independent networks I work with, all running various versions of RedHat Linux 4, 5, and 6. On one of those networks, I can't use bash (or, as I'm finding out, ...
0
votes
1answer
75 views

bash command in python not working

I would like to run a bash command from python. My code: process = subprocess.Popen(('ifconfig -s'), stdout=subprocess.PIPE, shell=True) output = process.communicate()[0] lcd.message(output) sleep(2) ...
0
votes
0answers
18 views

How can I format the piped and refreshing output of multiple cmmands nicely?

I have a command line of multiple piped commands which executes beautifully in bash. For simplification: command1 | command2 | command3 Each command generates output while running, resetting the ...
0
votes
1answer
26 views

How can I make shell autocomplete the beginning of a filepath?

I have a project with a deeply nested folder structure. Most of the time I know the name of the file I want to work with, but the folder path is too long/complicated to type when I want to edit it, ...
0
votes
0answers
14 views

cntlm to use hash instead of password?

As my title says I want to add hash in my /etc/cntlm.conf instead of directly pasting the password. So I'm using sudo cntlm -H -c /etc/cntlm.conf command but it is leading to a prompt asking to enter ...
1
vote
2answers
32 views

Expanding tilde convenience paths when using quoted paths in a bash script?

I have always used paths that aren't hardcoded inside quotes for my bash scripts. That way if the path (user inputed, user home dir, etc) happens to contain weird chars or spaces or dashes, my script ...
0
votes
3answers
57 views

Is there a way to determine which user ran a command in bash history?

We work on CentOS servers available to over a hundred employees via SSH, each with their own login. Running a normal history bash command shows all of the commands ran by all of the employees, however ...
0
votes
1answer
46 views

Use shell provided by non-root user

What is a good way for a non-root user to use an executable that is not in the system's list of shells as if it were the user's actual shell? I'm trying to do this with two different versions of ...
1
vote
1answer
24 views

PID of background task is different to the listed task PID using ps

Note: I h ave moved this to stack-overflow, I think that is the right place: here I have a strange issue, I can't quite get my head around. What I do is run a function called fn_rundumper which ...
1
vote
0answers
19 views

Bash partial glob expansion

I have a question similar to this one, but different: I want bash to use a glob expansion in auto-completion, if possible. For example, I would like $ ls *2.<TAB> To give me: $ ls mydoc2. ...
0
votes
1answer
18 views

Delete old backups alike Apple Time Machine does

Time Machine saves hourly backups for the past 24 hours, daily backups for the past month, and weekly backups for everything older than a month until the volume runs out of space. At that point, Time ...
0
votes
0answers
4 views

Use sfk list against only current directory (do not descend tree) or provide max-depth

The sfk list command does not mention any equivalent of max-depth. I want to use sfk-list in just a single directory or even better with an equivalent of max-depth Any way to achieve this? ...
-1
votes
1answer
60 views

How to run remote linux command that won't stop after closing shell

There is a Linux terminal command that I want to run on a remote machine. I can ssh to the machine and begin executing the command (it's output being directed to an output file); however, once I ...
0
votes
2answers
25 views

Combine the results of a CAT and TAC in a single window in Linux

I have two log files which I would like to view on my screen simultaneously. Below you can see my commands: pi@raspberrypi ~ $ watch -n 1 tac /home/pi/log/log.txt pi@raspberrypi ~ $ watch -n 1 cat ...