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

learn more… | top users | synonyms

0
votes
1answer
156 views

How do I build a script shell to send cmd via telnet and log only results?

I would like to make a shell script that can call a range of IPs via telnet, to send a command, and write the result to a file.
0
votes
1answer
122 views

ssh to production to www-data user

I build an automation for deploys, that we connect to our productions servers and then perform a git pull in the project. The project is owned by "www-data" so I need to to --> ssh ...
0
votes
1answer
219 views

Drush commands not found when called from a bash script

Relevant system background: I'm using MAMP on OSX. Output of which php is /Applications/MAMP/bin/php/php5.3.14/bin/php Output of which drush is /Applications/MAMP/bin/php/php5.3.14/bin/drush Output ...
0
votes
1answer
84 views

Memory usage of a process in a shell script

I want to find out the memory usage of a process in a shell script.I tried to use this piece of code : while[process] do if [ -e /proc/$pidno/statm ]; then m=`awk '{OFS="\t";print ...
0
votes
1answer
47 views

How to verifying variables correctly in Bash?

I have the following code: #!/bin/bash FILES=known/* arp-scan -l > temp_scan.log cat temp_scan.log | while read line do for f in $FILES do echo ...
0
votes
1answer
63 views

searching large number of possible file names in large directory tree

I need to search a large directory tree for a large number of possible file names, i.e. I have an input file with a long list of strings that I need to find in the tree (or as below: print all those ...
0
votes
1answer
112 views

“.” command doesn't work in fish

I'm using fish and I'm trying to activate a virtual env, so I tried "source" command which apparently is not available in fish. And I ended up with this link which says: ". (a single period) is an ...
0
votes
1answer
180 views

LINUX Bash - Recursively Create Intermediary Directories and Move Files of Type Into New Directories

I've used StackExchange before and lurked on SuperUser but first time posting. Here's what I'm trying to do. (Pseudo) For Each DIR containing $file *.Item Mkdir ./dir1/dir2 Mv $file ...
0
votes
1answer
36 views

in bash, how to load and execute an external bash script from a server, like github?

I'm thinking maybe I could have my ~/.bashrc (or other such customization bash file) live on my github and load it from whatever remote shell I log into with a command. Is that possible, and if so ...
0
votes
1answer
25 views

How can I prnt scrn to USB drive in bash linux

During early stages of installing linux, when in the bash terminal is it possible to screen capture and save the output to a mounted USB drive?
0
votes
1answer
30 views

Is there any difference in the view of process & sub process between command “/bin/sh -c ls /” and sh temp.sh(containing one line ls / only)?

What is the difference between the above ways of executing command and the code below? #include int main ( ) { int return_value; return_value = system ( "ls /" ); return return_value; }
0
votes
1answer
342 views

How do I capture what I see in tail?

Tail seems to parse TTY commands. When commands use ^M to erase the line & redraw the line in stdout, for example an animated ASCII progress bar. When I tail a file where this is happening, I see ...
0
votes
1answer
197 views

insert complex line in html file from the command line/bash script

I use a bash script to add a javascript file to a directory, but after that I need to insert into the index.html this line at between line 30 and 31. <script type="text/javascript\" ...
0
votes
1answer
51 views

Print Windows mapping of root path in MSYS Bash

In MSYS Bash I get: $ cd ~ $ pwd /c/Users/antonio but: $ cd / $ pwd / Can I get the full Windows absolute path from Bash?
0
votes
1answer
181 views

How to fg a process suspended before starting tmux inside the new tmux session?

How to 1. suspend a process with ^Z, 2. start tmux and 3. fg (or bg) the suspended process? $ find / [.....] ^Z [1]+ Stopped sleep 10 $ tmux $ fg -bash: fg: current: no such job ...
0
votes
1answer
190 views

tar -czvf with no output file

Say you run tar -czvf some_folder_here and don't actually specify an output file, like tar -czvf some_output_file.tar some_folder_here. Where does the file go? I just ran this by accident, and the ...
0
votes
1answer
330 views

grep: Invalid back reference for date expression in tcsh

I googled for the following error, and didn't get any great explanations as to what was going on with grep under tcsh. (Yes, that date expression exists in the log files). $ grep '2014-07-21' *.log ...
0
votes
1answer
79 views

stop all child processes when 1 of then returned exit code 1

I have 2 or more build processes to run in background. I want to stop all the build processes if one of them exit with code other than 0. ./build-1.sh & ./build-2.sh & ./build-3.sh & wait ...
0
votes
1answer
117 views

Bash prompt command being overwritten when invoking history/deleting command

My Bash prompt clears itself when deleting the text after it or going too far in the history. When logging in, the prompt looks normal. There are white brackets around a colored username and then a ...
0
votes
1answer
106 views

Is it possible to open a port for listening without netcat?

I have a need for a Linux system to listen on a TCP port and dump what it receives to a file and/or stdout. The system does not have netcat installed. I have root permissions, but am not allowed to ...
0
votes
1answer
39 views

writing a script to mail all users online

I am taking my first Linux class and we are writing scripts. Currently I'm trying to write a script that will look at who is online and then send them a mail This is an entry level linux class so ...
0
votes
1answer
199 views

Bash files open terminal when opened

This seems like something simple to do but for the life of me I cannot figure out how to do it. I would like all bash (*.sh, *.bash) files to open with a terminal to show their output in.
0
votes
1answer
93 views

Bash doesn't source file unless manually started

bash won't source files from an login terminal unless I manually run bash from a terminal, I have bash (and not sh or dash). When I source a file, it returs errors (like "syntax error near unexpected ...
0
votes
1answer
232 views

Unable to start bash script with shell_exec

I've been googling and trying to solve this problem with my php script for a few days now and I'm hoping someone here can see the problem I'm missing in getting my php script to kick off my bash ...
0
votes
1answer
47 views

How can I delete the oldest directory in a directory?

I am writing a backup programm, and I need to execute a bash command to delete the oldest directory in a specific directory. I have found this command to print the oldest directory: find -type f ...
0
votes
1answer
89 views

cygwin's chmod behaves as working, but it does not work

My Cygwin installation is behaving strangely: chmod does not work. [09:45 Administrator@DellIns14 ~] > ls -ls /usr/bin/chmod 64K -rwxr-xr-x 1 Administrator None 38K Feb 6 2012 /usr/bin/chmod ...
0
votes
1answer
453 views

Command Line: Browse to a network path that has spaces and a single quote

I am trying to browse to a network path in dos that has both spaces and a single quote. When I do: net use "\\server\path's name\folder\" I get an error message that error 53 has occurred. Any ...
0
votes
1answer
54 views

.bashrc used in gnome not just terminal

I've recently started using the Anaconda Python distribution for software development and I want it to be the default Python distribution when I run something in the terminal. In order to do this, ...
0
votes
1answer
351 views

How can I set the terminal encoding when running a crontab job?

I have a crontab job which executes a Ruby script on Arch Linux. It works basically, but when I call "googlecl" to post to my blog, it always shows a "safeDecodeError" exception (eg.: ...
0
votes
1answer
69 views

Trace web redirection in bash script

I want to make a script to download the image at best resolution (not the preview image) from a deviantART link, as if I clicked the "Download" button. However, it seems that deviantART redirect the ...
0
votes
1answer
86 views

running sac2xy returns sac2xy: cannot execute binary file on osx 10.9

I have a Python script for plotting data which uses sac2xy, but it gives an error when running sac2xy: sh: sac2xy: command not found the relevant part of code is : os.system("sac ./tmp/sac.m") ...
0
votes
1answer
17 views

Move child folders into a different folder

I am new to UNIX, and I am trying to write a shell script that would move all folders that are older than a day in log archive directory into another folder. Below is the command I am using for doing ...
0
votes
1answer
296 views

WGET/cron downloading webcamera file

our new town doctor put a web camera to his waiting room for people to see how much crowded it is. As my mom and grandparents go to this doctor, I wanted to download the files periodically and if they ...
0
votes
1answer
29 views

Removing files and directories that already exist in other directories

I need a help writing a script. So basically I have directories named by current date, like 01-06-2014 02-06-2014 and so on each of these directories has files and subdirectories inside. But sometimes ...
0
votes
1answer
99 views

How can I install my script into the user's $HOME/.bin (or $HOME/bin) directory and make sure that is in their PATH?

Edit: places where I said $HOME/.bin I should have written $HOME/bin or any equivalent is fine. So I have a bash script which I am distributing as a client for my API. Current version installs like ...
0
votes
1answer
179 views

Associate MIME Type with Shell Script?

I want to associate any file type with a .abc extension with the following shell script: #!/bin/bash echo arg 1 is: $1 The .abc type files just have text, but I want to ensure that opening a file ...
0
votes
1answer
137 views

Linux Bash SSH - Why won't my port forwarding tunnel command work?

The commands I'm trying are: ssh -vxNn -L 8080:192.168.x.xx:80 hostname@server ssh -vxNn -L 8080:192.168.x.xx:80 hostname@server Where the "x" is masked for security as is the hostname and server, ...
0
votes
1answer
132 views

not found error when executing bash script on Mac OS

I'm trying to build jDom-b4(a Java library) from the source with the script provided in the source. The content of script named build.sh: #!/bin/sh echo echo "Java and XML Build System" echo ...
0
votes
1answer
2k views

init.d script - Permission denied

I'm trying to create a init.d script for my server which should start/stop the teamspeak server and some node.js apps using "pm2". Here's my script: #! /bin/sh ### BEGIN INIT INFO # Provides: ...
0
votes
1answer
49 views

I accidentally put a space in my path then moved lots of files - where are they?

I used the following code to move a lot of files: sourceDIR=/Volumes/MCOOPER/data destDIR=/Volumes/MCOOPER2 /data for i in {1..6000} do mv $sourceDIR/run$i.mat $destDIR/ done Now all my files are ...
0
votes
1answer
169 views

Imagemagick text to file batch

I want to convert text to images, but the text varies. I would like to make this a batch job. This is my first stab at the problem: #!/bin/bash COUNT=$(ls -f *.jpg *.png *.gif | wc -l) for f in $( ...
0
votes
1answer
47 views

get a command process back after closing a session

Arrrgh! I'm using one of those drop down shells (guake, I think) on Linux. I'm dd-ing an SD card, and I accidentilly closed the shell session that was running that command. The light is still ...
0
votes
1answer
63 views

Error mounting in fstab Ubuntu

'm working on a bash class project which needs me to create 2 partitions in Ubuntu and make them be automatically mounted each time the systems boots with fstab. I got the following file which ...
0
votes
1answer
160 views

Using EXPECT script with a $ in the password

I'm trying to set a variable in a Linux bash script which includes a $ symbol, i.e. password is Gl@d1us$123 so PASS="Gl@d1us\$123". I can preceed the $ with a \ and it works fine, but when it calls ...
0
votes
1answer
135 views

Replacing subString in an array with bash

What I got: array[0]="Programm is Running" array[1]="programm is down" What I want: array[0]="Programm is \e[0;32mRunning\e[0m" array[1]="programm is \e[0;31mDown\e[0m" This will make things a ...
0
votes
1answer
51 views

What is the most effective linux program to perminanlty delete a file?

Some people recommend, whipe, srm, shred, etc. Is there one best assuming that the goal is to make a file irretrievable, regardless of time/space taken to delete? It would also be great if you could ...
0
votes
1answer
115 views

Brace expansion seemingly not working in Bash 3.2.51 on Mac OS X

I have a bunch of LaTeX files on my Desktop: ma 512 hw 11.log, ma 512 hw 11.aux, ma 512 hw 11.tex etc. I want to use brace expansion to print them to the Terminal. E.g., ls *.{log, aux} But ...
0
votes
1answer
262 views

Change ConEmu directory to working directory with Git bash

I currently have the following to open a git bash instance: -new_console:"%ProgramFiles%\Git\bin\sh.exe" --login -i The above starts the new tab in the home directory. I'd like it to start in ...
0
votes
1answer
173 views

Bash Sum Average numbers in files

I have a series of files with 2(two) lines. The first line contains a whole number (1-100) while the second line contains a decimal number(1.0000-99.9999). I need to get the sum of the first line and ...
0
votes
1answer
319 views

Better setting of EDITOR environment variable to use Sublime Text 2 as system editor?

I want to use Sublime Text 2 for editing Git commit messages. Right now I have the following in my bash rc file: export EDITOR="sublime -nw" This works well if Sublime is already running. But if ...