Bash scripting is making scripts in the Bash shell language.

learn more… | top users | synonyms

0
votes
2answers
414 views

Bash tar and output to log file

How can i write TAR operation in to a log file? tar -czvf arh.tar.gz public_html > 1.log TAR -czvf worked thanks guys! Now in bash script: for i in */ ; do ...
1
vote
0answers
110 views

Rsync do not do anything if files not changed

#!/bin/sh date=`date "+%Y-%m-%dT%H:%M:%S"` rsync -aP --link-dest=/target/current '/source/folder' /target/back-$date rm -f /target/Backups/current ln -s back-$date /target/current This is a little ...
0
votes
1answer
152 views

bash script to tar multiple domain folders

!/bin/bash sitedir="$HOME/domains" logs="$HOME/site_backups/log" tbackups="$HOME/site_backups/today" ybackups="$HOME/site_backups/yesterday" echo "`date`" > $logs/backups.log for i in `ls`; do ...
0
votes
1answer
92 views

Simple bash gpg update script

I have a text file in which I save all my important personal data like all my accounts' passwords and my credit cards' PINs in case I forget those. Obviously, that file needs to be encrypted, so I ...
-1
votes
2answers
110 views

zip subtitle files recursively on linux

I got 2 main folders Peliculas and Series, as you may guess Peliculas has movies on it (some of them on their own folder, the ones that have more than 1 file) and the folder Series has tv shows. What ...
0
votes
3answers
104 views

“cp --parents” equivalent on Mac

The topic explains it -- basically I have a bash script used on a Linux system and a Windows system with Cygwin where the following command works perfectly: cp --parents However, running this same ...
0
votes
0answers
45 views

Rsync delete issue

I implemented rsync to backup the data from the server to my local machine,and done it regularly by cron. It works fine but yesterday it deletes the files from the folders on my local machine but on ...
-1
votes
1answer
19 views

How to create a command line tool to set up web projects?

I am web developer, and everytime I start a new project, I have to set up my folder structure and starter files by hand. Is it possible to write a small command line tool (Bash) that does this for me? ...
1
vote
1answer
336 views

extract characters between first and second underscores of filenames and count such files in linux folder

I would like to extract characters between first and second underscores of filenames in a folder and count such type of files present in it. The folder contains files in a particular format such as : ...
1
vote
2answers
704 views

Apple Mavericks - why doesn't this one-line BASH script set my Python virtual environment like I expect?

I have the following Bash script: #!/bin/bash echo $MYPROJECT_HOME/bin/myproject_venv/bin/activate source $MYPROJECT_HOME/bin/myproject_venv/bin/activate echo ...
2
votes
2answers
85 views

Delete files and exclude some with find [duplicate]

It was an old problem. I knew how to delete files and exclude some, like this: rm `find ~/temporary/Test\ 1 -mindepth 1 -maxdepth 1|grep -v 'A'` but the problem is the folder 'Test 1' containing a ...
0
votes
1answer
403 views

Problems using EXPECT is a BASH shell script

This is the code (bash script): echo "Pass for router:" read -s pass /usr/bin/expect <<EOD spawn ssh 192.168.10.1 -l root 'opkg list-installed' > list-installed.txt #echo @pass expect ...
0
votes
1answer
409 views

Bash script to pull from master every morning

I'm trying to automate my workplace as much as I can, but I'm kind of new to bash scripts. What is the best way to tell bash script to run git co master and if it is successful do git pull and once it ...
0
votes
1answer
32 views

apt-cache show bash script

I'm trying to write a bash script that will ask echo "What programme do you want to see?" and then give the answer as 'foo', so that 'foo' can be read by the line which says apt-cache show foo|grep -i ...
0
votes
1answer
282 views

Start script on network connect

I am trying to get a GNU/Linux Bash script to run as soon as a network connection is established on my Raspberry Pi. I tried following the instructions on several pages: I have tried adding my script ...
0
votes
2answers
312 views

How can I add some websites link to browser's favorite(bookmark) for users in domain using batch script?

I wanna add some website's link into all users bookmark(favorite in IE) automatically when user log in to windows using batch script or something like that? Is there any policy in windows server 2003 ...
1
vote
3answers
103 views

Two simultaneous commands, then sequential commands?

So in Linux, I want to run a script 4 times, then do stuff to the output. I can do: script 1 > output1.txt script 2 > output2.txt script 3 > output3.txt script 4 > output4.txt cat ...
0
votes
1answer
144 views

How can a bash script run several others scripts?

I try to make a bash script to run multiple scripts located in different directories. I tried to do something like #!/bin/bash path1="/path/to/folder1" path2="/path/to/folder2" ...
0
votes
0answers
55 views

Geany IDE save files with bash command?

Is there any way to save open files in Geany IDE with a bash command? I have a bash script to compile source files for me, but I want it to save the file before compiling. "What I would like to use ...
0
votes
1answer
81 views

New process being created while checking with 'if' in bash

ps -ef | while read line; do for i in $line; do if [ $i = 'bash' ]; then echo $line; fi; done; done; unset i; The command runs properly displaying the Bash ...
2
votes
1answer
211 views

linux find: searching for files smaller than 2Kb misses the ones between 1 and 2Kb

I just stumbled in an oddity with the find command on Linux, in a nutshell I had the need to find all files smaller than 2Kb in a certain folder, so I issued the command: find /folder_to_search_into/ ...
1
vote
1answer
181 views

How to start a watch process for a bash script that sends notifications? (ubuntu 13.04)

I have written a bash script that monitors the output of sensors and uses notify-send to alert me when my notebook is overheating. I start the script with watch -n 15 fullscriptname and also added ...
0
votes
1answer
97 views

Bash conditional redirection when testing/debugging

What is the best way to conditionally do a redirection in Bash for testing and debugging purposes? In my scripts I add a debug option to show what would have happened effectively doing a test run ...
2
votes
1answer
64 views

How to properly restore settings when running a script using “source”?

I'm writing a script that needs to be executed using source, because its task is to modify the environment. During the script, I want to use set -e so that any error stops the script. The script looks ...
1
vote
0answers
157 views

Automatic generation of flowchart for in- and output files from BASH script? [closed]

Often I write bash scripts that can get quite complicated, even when they do not consist of a great many lines. I comment extensively, still it is sometimes difficult to understand what output files ...
1
vote
2answers
584 views

couldn't execute “mysql”: no such file or directory, using autoexpect

I have the following file: exp.exp #!/usr/bin/expect db_host='localhost' db_name='webui_dev' db_user='root' db_pass='rootpass' new_db_name='db_2011' expect <<EOF log_user 0 spawn mysql -h ...
1
vote
2answers
87 views

Bash Script Error

I'm trying to write a bash script to manage setting up a user profile. I can't seem to figure out why this if statement won't work. I have the code: #!/bin/bash #check if programs are installed ( ...
1
vote
1answer
130 views

Stuck in a while-loop in GNU/SU (seismic unix)

I'm new to programming. I have this loop (it's part of a data processing script) and I have it all good until this section cause I can't figure out why it stay looping in the second 'while' Take a ...
2
votes
1answer
421 views

A bash script to start applications in certain workspaces [duplicate]

I'm dreaming of a Bash script that opens applications and places them in certain workspaces. For example, I'd like to run a script that: In Workspace 1 opens firefox WS2 - opens term and maximizes ...
3
votes
1answer
518 views

How to get list of all child process spawned by a script

Context: Users provide me their custom scripts to run. These scripts can be of any sort like scripts to start multiple GUI programs, backend services. I have no control over how the scripts are ...
-1
votes
2answers
72 views

Bash: Escaping list of files

Can this be done more nicely (echo a placeholder for another command) echo $(for x in *;do echo $x|sed 's/\([ \t\n\r\v\f\;#]\)/\^\1/g'|sed 's/$/\;/g';done) Also, there should be no ; after the last ...
0
votes
2answers
437 views

Getting error no such file or directory when running a script

Need a bit help. I just wrote my first script to change the network configuration. the code is echo "changing IP to 172.17.51.71" echo "changing Mask to 255.255.255.0" echo "changing Gateway to ...
1
vote
0answers
4k views

how to get flash video stream URL from website without browser (telediario, rtve)

I want to access the video stream URL of telediario from spanish television (RTVE) which you can find here in a flash player: http://www.rtve.es/alacarta/videos/telediario/ I want to do this with ...
2
votes
1answer
85 views

Invoke a script for every command typed at shell prompt?

On bash, is there any simple way to run a command every time another command is entered in your shell? I know about 'trap ... DEBUG', but unfortunately it does not run the specified code for every ...
0
votes
1answer
652 views

set global variable AND use stdout from bash function

Here's the code: #! /bin/bash function foo() { G1=123 echo "ReturnVal" } RV="$(foo)" echo "RV=$RV, G1=$G1" # RV=ReturnVal, G1= foo >/dev/null echo "G1=$G1" # G1=123 I want to execute ...
0
votes
1answer
1k views

Save result of a grep -c into a shell variable

How can I store the result of grep -c as an integer in a shell variable? This: check=sudo virsh list |egrep -c '\b[0-9]{2}\b' only gives me the number of matches and prints it on screen whereas ...
3
votes
2answers
115 views

Append dir to PATH

I'm trying to localy add a dir to the global $PATH variable. I added the following to my .bashrc. export PATH=$PATH:$VRS/bin But PATH seems to get concatenated to itself over & over every time ...
2
votes
2answers
381 views

Prefix to each output of a command on runtime

I am trying to make a modular script. I have several scripts/commands which are called from a single script. I want to prefix the output of each separate command. Examle: My files are allcommands.sh ...
0
votes
1answer
240 views

Getting error while executing shell script in Cygwin?

I have done a script (bash) and kept the same in E:\Ping folder of my local Windows 7 m/c, and I am trying to run the same through Cygwin. I'm getting a bash: sh : command not found error. What is ...
1
vote
1answer
739 views

Removing files older then 1 month, but leave one file per month

I try to script something similar to Removing files older then 1 month, but leave files created at the 1st day of the month. The difference is that I need one file per month. I am using the script ...
-1
votes
1answer
158 views

Making a user creation script for web server [closed]

Ok, so I'm building a webserver and MySQL server from scratch... Server A is going to have Apache and PHP Server B is going to have MySQL Both servers are running Ubuntu 12.04 LTS server I plan on ...
-1
votes
1answer
179 views

while loop in bash until file size does not change [closed]

I'm trying to do the following while loop using a bash script file_size = 0 temp_size = 1 output_file while (file_size != temp_size) temp_size = file_size download file append to ...
2
votes
3answers
199 views

Shell script not running as by “./” but it runs by “sh”

I am running a script on arm target board as a super user, i.e., as a root user. But the script is not executing if i run it with following syntax root@freescale$ ./Script.sh -sh: ./Script.sh: ...
0
votes
3answers
112 views

Possible to use more than one core with sed and bash?

I am looking to use more than one core when replacing values with sed in bash, is this possible?
0
votes
3answers
902 views

How do I parse a line thorugh a file in bash

I am very new to shell scripting I had a small query regarding the file parsing. So, here's what I am trying to do: I run an svn merge command, and genaratea conflict file my conflict file is ...
0
votes
2answers
379 views

Trying to find any home directory that is writable by anyone

I am trying to locate any user home directories and their files that are writable by anyone. I wrote this: find /home -type d -perm -200 | grep . || echo no world-writable directories here ...
0
votes
1answer
146 views

Batch processing in Linux?

What kind of script I need to run a batch on Linux? I have to launch this line php magmi.cli.php -profile=FINALE -mode=create -CSV:filename="path/to/file01.csv" 40 times for 40 different CSV files ...
0
votes
2answers
455 views

Mac OS X login script for specific user

I need to be able to run a bash script every time a specific user logs in. The solution here is for all users. Is there any way to specify the user, and if not is there a way for the bash script to ...
1
vote
2answers
299 views

Why does xmessage report that user clicked 'x' without displaying message when run from cron?

I have the script below, which seem to work perfectly when run from the commandline with /root/.scripts/peter-laptop-backup-launcher.sh daily (it displays an xmessage asking what I want to do), but ...
0
votes
3answers
247 views

Is there any way to encapsulate bash functions?

I'm writing a simple script script.bash that is supposed to export some variables environment, to use it in my current session I have to source it $ . script.bash script.bash function fun1() { ...