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

learn more… | top users | synonyms

1
vote
0answers
39 views

Purpose of function export in bash

If we take a look at the following example: # testing(){ echo hello;} # testing hello # echo $(testing) hello # echo testing >script # ./script ./script: line 1: testing: command not found # ...
0
votes
1answer
28 views

Alias to attempt mounting multiple times doesn't work correctly

I have the following in my .bashrc alias ext='sudo mount /dev/sd'{b..d}'1 /ext/hdd || sudo' I intended the alias to mount my external hard drive without having to worry about the semi-random ...
0
votes
1answer
27 views

VSFTPD Refusing Connection Debian

Trying to setup VSFTPD to use with ShareX for file and image uploading. When checking on the status i get this root@vps:~# /etc/init.d/vsftpd status ● vsftpd.service - vsftpd FTP server Loaded: ...
2
votes
1answer
21 views

Tmux - Detach client fails if using bash startup script

Typically, I use a bash script to create my tmux session (split panes, set PWD, call commands, etc.). This works great, except if I try to run tmux detach-client. It will fail to detach, instead just ...
1
vote
2answers
48 views

Cronjob not running script

I've created a script to get my external IP address, check if it's changed and if it has, email it to me letting me know. Here's the script, aptly named ip.sh (server hostname is "odin"): #!/bin/sh ...
0
votes
0answers
16 views

linux + verify by ssh the remote machine configuration

what is best way to verify if the remote machine is cluster machine I just create the following ssh command to verify if the remote machine is VRTS cluster or Linux availability Red Hat cluster ...
2
votes
1answer
69 views

How to disable automatic escaping of quotes - BASH

I have this test code in my bash file: gtest() { echo 'hello' } bind '"\C-g\C-x": "$(gtest)\e\C-e"' When I start typing something like vim ", and then press C-g C-x, I get vim hello instead of ...
0
votes
1answer
15 views

How to iterate through Hosts in .ssh/config

On some of my remote servers I use Git to keep commonly used scripts in sync. I would like to have a local script that I can fire to update all remote servers that that are within one domain range. ...
0
votes
1answer
18 views

Why are spaces not allowed while setting up aliases in .bashrc

Coming from the Windows world, I tend to type cls to clear the console. I wanted to set up an alias so cls would still work. I read an article online that mentioned you cannot have spaces between the ...
0
votes
0answers
24 views

Full text, dynamic, RSS feed generator

I am looking for a solution to produce and update regularly full-text RSS feed. The goal is to provide full text feeds from a variety of websites to my canto rss reader. There are several services ...
1
vote
2answers
21 views

when performing a read command from within an xterm -e, it doesn't store the result of the read

When running the following in #!/bin/bash xterm -e "echo 123;read ANSWER;echo answer=$ANSWER;sleep 5" I get these results in an xterm window (no matter what i type for the read). 123 answer= So ...
1
vote
1answer
42 views

How to run a sequence of bash scripts one at a time in Linux?

I have several bash scripts, or rather one script that has to be run multiple times. This script accepts several command line arguments and does something with them. I need to run this script ...
0
votes
2answers
34 views

In bash, how to combine the output of two commands and append them on the SAME line of a file?

For example I have two commands here: { command1 & command2; } >> file1 For example the output of command1 is 400, and the output of command2 is 4. So this is what I get: 400 4 I want ...
0
votes
0answers
23 views

bash: illegal character in an environment variable

According to man bash, bash identifiers may consist: "only of alphanumeric characters and underscores", however, bash seems to have been tolerant to this up until shellshock patch. Actually, it still ...
40
votes
5answers
4k views

How can I make my own “shell commands” (e.g. mkdir/cd combo)?

I can't tell how many times I have wished for a command that would both create a directory and move to that directory. Basically, I would like the equivalent of the following: mkdir -p /arbitrarily/...
1
vote
2answers
41 views

Source by bashrc when I exit an ssh session

I'm on OS X and using iTerm2 I've updated my bash profile on several of my servers so that when I ssh into them I can tell at a glance from the tabs what boxes I'm on. when I exit from an ssh session,...
0
votes
1answer
46 views

How to transparently substitute sha1sum for shasum in sh shell?

I have a test that needs to run on multiple platforms. On all other platforms, the test uses sha1sum, but on my Mac OSX El Capitan, there is no such program installed, but shasum works fine as a ...
0
votes
1answer
26 views

How to erase certain lines from 10000 files efficiently

I have 10000 files in a directory. I would like to erase lines so that I keep 2 lines in the header, 2 lines at the tail, and every 100th line in the middle. For instance: #header1 #header2 0 x ...
0
votes
0answers
57 views

Bash storage on Windows 10

Where on the file system does Bash for Windows get installed? If I find that it becomes bloated (because over time I installed a lot of apt packages or something) what is the best way to purge it and ...
0
votes
1answer
57 views

Linux: shutdown from GUI vs from terminal

Hello I'm new with Linux and could not figure out if shutting down computer from GUI is the same as from terminal with command: shutdown -P now P.S When shutting down, Does init process receive ...
2
votes
1answer
29 views

Why am I able to switch user only using hyphen?

If I try to switch the user using sudo su - kshitiz it works, and doesn't ask me for any password. But if I do sudo su kshitiz it asks me for that user's password. Why is this? I understand that ...
1
vote
1answer
148 views

How to pass nmap outout to a Python script

I have a list of server, and I want to nmap then pass to a Python parser (this) So normally I do this: nmap -sV -p- hostname -oN - | python nmaptocsv.py > hostname.txt Now I want to create a ...
1
vote
1answer
38 views

Curl command to download a file over HTTPS

I need to download a particular file from https://file_path. Here is the curl command I use for that: curl --user user:password "https://file_path?raw" > location I wish to download the real ...
0
votes
1answer
27 views

Using a particular version of java in a specific directory

My current default version of Java is 7 (which, for now, can't be updated - I know it's reached EOL), but also have Java 8 installed. However, I have some third party jars (all contained in a ...
0
votes
1answer
50 views

Watch with awk command

How do you watch a command like? awk 'NR%2==0 {printf "%s %8.0f", $1, $5}' filename.txt Preceding this with "watch" gives this error: awk: cmd. line:1: fatal: cannot open file `{printf' for ...
0
votes
1answer
13 views

Bash script to get nested http response from URL

I have a scenario where I am deploying applications to a Tomcat instance using a bash script and need to test if the endpoint (a login screen in this case) is truly available by testing it before I ...
0
votes
4answers
93 views

bash - What does {} means?

I want to delete files, which have size = 0. So I tried: find ./ -size 0 | xargs rm But it has a problem with files, which names begin with space. I found this: find ./ -size 0 -exec rm -i {} \; ...
0
votes
1answer
100 views

What does a question mark after the file name mean using ls terminal command?

What does a question mark after the file name mean using ls terminal command? I am using a Mac running OS X Yosemite (v.10.10.5) When I do ls command at terminal, I get back a list of files (the same ...
0
votes
0answers
35 views

Deleted a Windows folder using Linux command rmdir -rf foldername

I have a folder on a Windows 7 machine with contents in it and decided to delete it using Git Bash, namely with the command rmdir -rf foldername. According to this manual http://www.computerhope.com/...
1
vote
1answer
36 views

Completion of arguments for Cygwin commands not working due to `.exe` extension

When using tab completion in Bash on a Cygwin system to complete the name of a command, the .exe extension is appended to the command name, e.g, typing opens and pressing Tab completes the command to ...
0
votes
0answers
32 views

issue launching atom via git bash shell

I am trying to launch atom from the git bash command line. Sometimes atom has some sort of an auto-update feature where it upgrades itself. And when that happens, you may notice something on the ...
0
votes
1answer
41 views

Changing my shell bash script default $PWD to it's (the script's) current location

Hey I'm running my shell script that interacts with folders and files, but my $PWD that it keeps pointing to /home/MyUserName directory and this messes with what it is supposed to do. I am running ...
1
vote
0answers
12 views

`qsub` leaves “NotQueued ” in “blocked jobs”

I am working on a remote cluster (westgrid > bugaboo) on which I submit processes via a .pbs file. My .pbs looks like this #!/bin/bash #PBS -l procs=1 #PBS -l walltime=100:00:00 #PBS -N ...
0
votes
1answer
26 views

Pattern search the user input in a file in Unix using awk

I am trying to write awk script to search for a pattern that is given input by user, in a file. My code look like this: awk 'BEGIN{printf "Enter : ";getline input<"/dev/tty"} /'"$input"'/ {print}' &...
0
votes
1answer
25 views

What is the difference between \e[38;5;175m and \[\e[38;5;175m\] as it relates to bash colors?

I have been trying to learn how to customize my shell and I came across two different ways of specifying colors in the Bash shell. They both seem to accomplish the same goal and I am not sure what (if ...
0
votes
1answer
95 views

Background process with stdOut/StdErr output in files and console

I want to SSH into a machine, start a process, write the stdErr and stdOut of the process into two seperate files while reading the stdOut/stdErr in the console. As soon as some specific lines were ...
0
votes
1answer
24 views

Can we install a package through a shell script? [duplicate]

I'm trying to write a shell script so that when I reinstall my Ubuntu again. I could just run script and retain all the packages. And I'm planning to pass password in form of argument. My question ...
0
votes
0answers
28 views

How to have error output from `ls` if target directory is empty

I'm currently learning how to use the Linux shell, getting to grips with the basic commands like cd, ls and pwd. My file structure is like so: user |-- documents |-- file1.pdf |-- file2.txt |-...
0
votes
2answers
54 views

tail/head all line except X last/first Lines

for example i have this file : cat myfile 1 2 3 4 5 i want to print all lines except first 2 line . output should be like this : tail -n $(( $(wc -l myfile | awk '{print $1}') - 2 )) myfile 3 4 5 ...
0
votes
2answers
25 views

why doesn't xterm work with my script?

my script : echo 123456 > /folder/folder/123.txt I ran the script with xterm: xterm -e my.sh & It doesn't work.
0
votes
2answers
20 views

find -exec where filename is not the last parameter

I am trying to pass the files from find command to adb push like this: find . -name "test0[4-8]*.py" -exec adb push {} \; /storage/emulated/0/ I get an error find: paths must precede expression:...
2
votes
1answer
19 views

Execute SSH port forwarding along with the browser

I've successfully set up dynamic port forwarding over SSH in Pale Moon and added the alias as ssh-forward in .bashrc. Now I have to execute both ssh-forward and palemoon to access the Internet over ...
0
votes
1answer
33 views

How to pipe binary stdout to a compressed tls connection?

Not so long ago, I could use : cat somefile.txt | openssl s_client -connect server:port -quiet -comp However, this command doesn’t work, even with-ign_eof: $ cat somefile.bmp | openssl s_client -...
0
votes
2answers
53 views

From logs, extract specific line after a grep by line number

I have a file, debug.log, from which I want to extract all the lines that immediately precede a specified pattern. Example: 1 blabla 2 blabla 3 HERE THE IMPORTANT THING 4 HERE IT MATCHES MY PATTERN ...
0
votes
1answer
14 views

lost virtualenv display to the left of bash prompt

I added thy Holy prompt to display my current branch so I never push to master. We all use it and it works, but I am no-longer seeing what virtualenv I'm using at the moment, which is a hassle. Based ...
3
votes
1answer
73 views

How to pipe AWK command output to Python as first argument

I have a plain text file input.txt which looks like: D000001 D000001 44 1975 D000001 D000408 1 1983 D000001 D000641 1 1977 D000001 D000900 27 1975 I process this file using simple AWK line: awk '{...
1
vote
1answer
14 views

grab history command and args for different commands

I have the following exercise: 47 vim wilson.0321 wilson.0329 I need to grab the last command and args to create: vim wilson.0329 right now I can grab the last arg or entire command: ...
1
vote
2answers
99 views

Cygwin paste long line is inserting newline at wrap point

I'm having issues with Cygwin's Copy/Paste functionality on a fresh install. If I scrunch my cygwin window small, and then type a command that is wider than it is (such as echo ...
0
votes
0answers
23 views

How to expand a loop iterating over an array dynamically in BASH?

I need to iterate on an array and expand the array while iterating. How do I do it in BASH? For example: req="a b c d" read -a MODULES <<<$req for MODULE_NAME in "${MODULES[@]}"; do ...
-3
votes
1answer
55 views

What is the use of Bash in the next update for Windows 10? [closed]

In the Build conference this last month, Microsoft said that Bash was going to be introduced in to the anniversary version of Windows 10 in July. And I thought to my self, would this be an advantage (...