Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

1
vote
1answer
176 views

Cygwin browser script error

I use multiple browsers, and I created a bash script that checks to see which browser is open and opens web pages in whatever browser is already open. I use Windows 7, so I run this script using ...
0
votes
2answers
311 views

Root set environment variables

I have a small bash script which downloads a critical file, opens an SFPT connection, puts the file and closes the connection. As you can imagine, my script has some username and password information ...
1
vote
2answers
58 views

Outputting less into a file

while on bash, i tried to delete the 3 last columns of a file using: head -n -3 file > file but the file comes out empty. I can walkaround it but I would like to know what causes that. Thanks a ...
0
votes
1answer
215 views

Determining if an argument looks like a valid path

I'm writing a bash script that needs to perform some operation on an argument which is a path The path may or may not correspond to an existing file on the user's system, so I'd like to test whether ...
0
votes
1answer
31 views

Environment auto-install

When I work, I often have to switch computers or virtual machines which means that every time I switch, I have to set up my (Linux) environment again. My question is the following : Is there a tool ...
0
votes
1answer
1k views

Can't edit '/etc/network/interfaces' file through bash script in Ubuntu [duplicate]

Possible Duplicate: sudo permission denied I got need to edit /etc/network/interfaces through bash script, I am doing something like below... sudo echo something > ...
0
votes
1answer
249 views

bash getopts, parsing ranges

What would the best approach be to parse argument value ranges using getopts? As an example: $ script.sh -r2-4,6,8-10 In my script I would then have an array with the values 2, 3, 4, 6, 8, 9 and ...
3
votes
1answer
361 views

Script-specific autocomplete in shell

I create a lot of little scripts to help me in my every day life. I would like to provide auto-complete for them, specially that I intend to share them with people. Now, I know I can create ...
-1
votes
2answers
1k views

Execute multiple commands in one line inside unix shellscript

The question is somewhat related to the question asked here, http://stackoverflow.com/questions/5130847/shell-multiple-commands-in-one-line, but the difference is, I need to execute the whole commands ...
3
votes
3answers
67 views

merge pieces of file together

I have a directory tree of files I need to loop through and reformat the lines. can I do this with sed with some combination of find? for each file, I'll need to adjust the text in the file from ...
1
vote
2answers
456 views

Assign values or string to a variable in linux scripting

I am trying to assign the output of the basename command of a file to the variable "filename". paths is a file that contains the path location, e.g /root/home/david/mynote $FILE is = mynote. grep is ...
0
votes
1answer
39 views

Run a specific command from a directory

I have a bash script where I need to run an init utility within a directory with a configuration file defined. I don't think it's possible to explicitly tell the utility to run the file as an ...
0
votes
2answers
1k views

Automounting SD card when inserted in Ubuntu

I am trying to write a BASH script that automounts an SD card once it is inserted in the card reader, then move all pictures to a folder in the HDD and renaming each file to the date and time the ...
1
vote
2answers
205 views

Revising a bash script - Invoking a change of prompt color via a temporary file

I am wondering why the following script won't work: #!/bin/bash read -p 'First lets write PROMPT.SH' echo '#!/bin/bash'>prompt.sh echo "export PS1='\e[1;31m\]\u@\h \W\$\e[0m\] '">>prompt.sh ...
5
votes
2answers
1k views

Writing shell scripts that will run on any shell (using multiple shebang lines?)

I've just started getting deeper into shell scripting, and I've always just thrown my script in a file, marked it chmod +x and then done /path/to/script.sh and let whatever interpreter is the default ...
0
votes
0answers
73 views

gnome-terminal flag sh

I'm extremely new to linux, so i kinda need some tutoring... been teaching myself some scripting. Most of the stuff I just copy of sites. what baffles me is the little flags that appear in this line: ...
0
votes
1answer
165 views

output redirection not happening completely

I am running the following command on ubuntu 12.04 bash shell: hping3 -S -p 80 -c 30 www.google.com >> outputfile.txt But the problem is that this leaves some lines in the end and doesn't ...
1
vote
3answers
1k views

How could I make a bash script to execute apt-get?

I'm trying to automatize some configurations I have with bash script, I've never done this before so I tried with something easy like a Hello World! and everything works just fine, but then I tried ...
0
votes
3answers
1k views

Run shell script on Linux box from a shortcut/app in Android?

I have an Ubuntu box which runs XBMC, which crashes occasionally. Since I have no keyboard connected,I have to SSH in, kill xinit, then restart it. I was wondering if there's an elegant way of doing ...
0
votes
1answer
889 views

Advanced merge directory tree with cp in Linux

I need to: Copy all of a tree's folders (with all files, including hidden) under /sourcefolder/* preserving user privileges to /destfolder/ If there is a conflict with a file (a file with the same ...
3
votes
3answers
105 views

Why doesn't this script work?

I've been using this bash script: for i in $(ls); do mv $i a$i; done to prepend all filenames in a folder with the letter a. I'm afraid that at some point I'll accidentally use this script in the ...
0
votes
1answer
448 views

My bash script does not find an existing file (into the script's wd) which name I passed as a parameter in a function

I realized a bash script that works on an existing text file located into the same working directory of the script. The script take name of the file to compute through a function parameter. The issue ...
4
votes
1answer
48 views

How to filter output from a command in OS X

I am in need to monitor the the writes from an unknown application to a known directory through creatbyproc.d. I'm going to have to leave this up and running for up to 36 hours which will not be ...
0
votes
1answer
102 views

Bash delete file when variable = x

I'm creating a bash script which reboots the system at each reboot it adds a new line to a text file, I then read the text file before each reboot. Once the variable holding the number of lines ...
4
votes
1answer
301 views

BASH function not escaping control characters

Hey guys I have a function that I'm using to find stuff, but unfortunately anytime I pass it a control character ($intVal or testing : etc) it chokes. I was wondering what the fix was? I can ...
1
vote
1answer
3k views

Howto switch / chage user id witin a bash script to execute commands in the same script?

Is there a way to switch user identity within a script (executed as root as part of an installation process) to execute some commands without calling an external sctipt, then be back to root to run ...
2
votes
2answers
304 views

concatenate files including path in header - path contains spaces

I have to concatenate a number of files in a directory structure which contains spaces in the folder names looking like this: ./CH 0000100014/A10/11XT/11xt#001.csv find . -name "*.csv" -type f ...
3
votes
1answer
57 views

Checking pids under all users and re-launching the processes after reboot

Is there a way to check all pids of all users under /home directory, and to run these processes again after a reboot or shutdown? For example, if user1 was running a psybnc and user2 was running an ...
0
votes
2answers
492 views

keep environment when executing in script

I have a bash script that should be executing a number of commands. The commands work fine when entered in a termainal but when I try to execute them from inside the script they don't work, so I ...
0
votes
0answers
187 views

Getting a setting, the chdir value, out of GNU Screen

I've been using screen's chdir command to set a new working directory for new screen windows, more on that later. What I need to do is find out what the setting was before I set it, so that I can set ...
1
vote
1answer
340 views

How to calculate and group the time differences of specified syscalls when running strace

I'm planing to do some web performance testing (to see how much time it's spent for each file), but it could be useful for any application. I exactly know existence and how to use different ...
1
vote
1answer
421 views

Scripting output of a telnet connection

Another whois question, is it possible for me to take the output of a telnet connection to a file. telnet whois.internic.net 43 then I =google.com and get a response. Can I get this to return ...
2
votes
2answers
337 views

Word splitting does not see my quotes

Imagine I have this $ ARGS='"a b" c' $ for arg in "$ARGS"; do echo "$arg"; done "a b" c $ for arg in $ARGS; do echo "$arg"; done "a b" c The result I'm looking to get is $ <???> a b c How ...
8
votes
3answers
4k views

Truncate file by lines

I have a large number of file, some of which are very long. I would like to truncate them to a certain size if they are larger by removing the end of the file. But I only want to remove whole lines. ...
0
votes
1answer
140 views

linux bash backgrounding and I/O redirection

I'm having bash backgrounding and file redirection issues. I need to attach to a remote sensor box and record the ascii datastream from that box onto disk files. I'd like to break that datastream ...
0
votes
1answer
212 views

How to quote a command between backticks when shell scripting

The command executed in the following script works: #!/bin/bash -xv REM_DIR="/home/jan/rem-dir" SSHOPTS="-C -c arcfour256 -o "\""ServerAliveInterval 15"\" SSHUSER="jan@example.com" CMD="ssh $SSHOPTS ...
6
votes
2answers
64 views

Process files in a folder that haven't previously been processed

I have a series of files in a directory that I need to carry an action out on using a script. Once the action is done, then I want to keep a log that the file has been processed, so that the next ...
0
votes
3answers
511 views

Customizing BASH output colors?

How do I customize bash colors for command output? For example; I run ls and want directories and files to be a different color. How do I accomplish this? I see that distro's are doing this but I ...
0
votes
2answers
94 views

Showing a stack of ssh connections in terminal

I had this idea for long time and tried several ways to implement, with no luck. Tried to google many times and always finding not quite what is needed. How to do: $ ssh hostA ...
0
votes
1answer
357 views

IP Address dotted decimal to /8 or /16 notation using bash,sed or awk?

I have an input file that contains a list of ip addresses and the ip_counts(some parameter that I use internally.)The file looks somewhat like this. 202.124.127.26 2135869 202.124.127.25 2111217 ...
0
votes
1answer
450 views

How can I create session logs of individual SSH sessions?

Here is what I am looking for: A way to log individual SSH sessions on SunOS. I would like to have the files kept separate based upon the hostname of the device I am SSHing into. I am only using ...
1
vote
2answers
114 views

What's the easiest way to 'cat' groups of files together?

I have files with naming convention of this pattern: bond_7.LEU.CA.1.dat bond_7.LEU.CA.2.dat bond_7.LEU.CA.3.dat bond_12.ALA.CB.1.dat bond_12.ALA.CB.2.dat bond_12.ALA.CB.3.dat ... I want to ...
0
votes
2answers
192 views

Applying a filter to all arguments of cat

I have a list of files on a server, let's say matching the pattern http://example.com/abcd-{0..99}.zip. I want to download, then decompress all these files (they're just zipped text, with one file in ...
2
votes
4answers
3k views

awk / sed to print only up to the underscore character

How can I use awk or sed to print a string only up to the first underscore character? Before: host100_044 2 host101_045 2 host102_046 2 After: host100 host101 host102
0
votes
2answers
271 views

bash: ./wls1036_solaris32.bin: Invalid argument

Having some experience in ubuntu, I installed solaris 11g recently to work on WebLogic. I've downloaded wls1036_solaris32.bin file. When I run ./wls1036_solaris32.bin in the terminal, I'm getting ...
0
votes
1answer
258 views

how to extract string from text using shell script

i have the following text A shell script is a (script) written for "the shell", or command line interpreter, of an operating system. The shell is [often] considered a "simple" domain-specific ...
0
votes
1answer
2k views

Create a tar and splitting it into multiple archives then putting them back together

I am using the following for creating the tgz files: tar zcf - /usr/folder | split -b 30720m - /usr/archive.tgz Now I get three files: archive.tgzaa, archive.tgzab and archive.tgzac So again I ...
0
votes
2answers
257 views

sound detection accessing device node directly

I am attempting to invoke a bash action triggered by audio input. A very simple sound detection sensor (no record) with adjustable threshold utilizing a pc's onboard audio chipset and audio microphone ...
0
votes
1answer
1k views

Expect script inside bash script optional statement

Using: CentOS 6.2 BASH shell My script is something along the lines of #!/bin/bash INSTALL_PATH="Enter install path" CR="\n" /bin/su root -c "/usr/bin/expect << EOF spawn name.run expect ...
0
votes
2answers
60 views

Has Anyone Made a Program to Manage Scripts (Non-CM)? Recommendations?

I find myself often writing shell scripts in Linux and losing track of them over time. What I would love is a program that stores a copy of the script, along with a descriptive note I write at the ...