0
votes
2answers
24 views

using 'case $1 in' to read command options- multiple flags after dash, and handling unusual flags?

I am making a bash script which uses both long options and short flags. Since I want long options, I can't use getopts. I tried using the following code: while test -n "$1"; do case "$1" in ...
0
votes
1answer
21 views

Calling a list of functions provided on a stream

I'm writing a bash script to configure a server in which the end user will have to choose the actions to perform and the script will execute them. Each action will be implemented as a function. I've ...
0
votes
2answers
79 views

Getting errors trying to run shell script (Linux)

I'm trying to run the following script. I have run it before without issue, but now I encounter an error. #!/bin/bash # init function pause(){ read -p "$*" } echo & echo "(Website):" ...
0
votes
1answer
23 views

pass filename(with space in the path) as argumant to a wine app in a bash script

I want to luanch an wine App with passing a file as argument. I've two file, with the first I don't have any problem but when there is a space in the path wine can't handle the address properly. here ...
0
votes
1answer
18 views

Renaming files in a folder (and subfolders) by removing a token in filename

I have a huge amount of files in a folder (and subfolders) that I need to rename. For example, I have: movie1.mp4 fixed_movie1.mp4 ... What I need is to rename fixed_movie1.mp4 to movie1.mp4 ...
0
votes
1answer
14 views

Backing up github [closed]

I have a bunch of github directories and have been using a script with the "cp" command to backup to an external USB drive. I was wondering if I should be backing up directories that I make for ...
0
votes
2answers
45 views

Properly escaping forward slash in bash script for usage with sed

I'm trying to determine the size of the files that would be newly copied when syncing two folders by running rsync in dry mode and then summing up the sizes of the files listed in the output of rsync. ...
1
vote
1answer
39 views

Unable to delete a file using bash script

I'm having problems removing a file in a bash script. I saw the other post with the same problem but none of those solutions solved my problem. The bash script is an OP5 surveillance check and it ...
-1
votes
0answers
29 views

Bash Syntax, While Loop. User Input

I have a problem with some Bash syntax. I want to read User Input while that User Input is not Y or N. this is the code i have; read input while [ $input <> "N" ] || [ $input <> "Y" ] ...
2
votes
1answer
31 views

Are shebang invocations detectable?

Is there a way for a bash script to detect if it's being run via the #!/usr/bin/env shebang? Some magic bash foo that would let me write: #!/bin/bash ... if [ __INVOKED_VIA_USR_BIN_ENV__ ]; then ...
0
votes
1answer
53 views

Execute the shell command in subshell or in background?

Actually I mainly work with Ruby, but now I have created a bash script file. From this script file I am displaying the messages on the screen. Here is my scenario. I have used aosd_cat module for ...
1
vote
2answers
34 views

How do I print multiple sections in a text file?

I have a text file looking something like this: *FILESTART line_a line_b line_c *INCLUDE file_A.key file_B.key *INCLUDE file_1.key file_2.key file_3.key *SOMETHING_ELSE line_x line_y line_z *END I ...
1
vote
2answers
41 views

How do i run su username -c “command ” in a sequence

am trying to write a script that runs commands in a sequence as a user but su keeps doing every command at the same time instead of running them one after another the script looks like su username ...
0
votes
0answers
40 views

Autoexport bash internal variables

I need to access to some bash internal variables (BASH_LINENO, BASH_SOURCE) from a command invoked by a shell script. The only possible interface between my command and the script are environment ...
1
vote
1answer
84 views

HandbrakeCLI bash batch script not working.

I am trying to batch encode a bunch of files. Looking over the internet I have found just a couple scripts and none of them worked for me. I started to piece together something and it is close to ...
2
votes
1answer
23 views

Can you delete all users but specified accounts in Ubuntu?

I am trying to find a way to quickly delete all user accounts except for the ones I specify in Ubuntu. Is there a good way of doing this? Perhaps a bash script that could do this function? I ...
1
vote
1answer
29 views

Move Files having No Extension

I have 5 files in a directory log.txt abc.pdf def.ppt 1CC 1DD Now I want to Move files having no extension i.e 1CC and 1DD to a another directory i.e tree. whenever i am manually using command it ...
1
vote
1answer
39 views

Find last 24 hours executed commands per each user in bash

How can I find last 24 hours executed commands per each user and mail them the result? I have Ubuntu GNU/Linux. I find out that I need a package named 'acct'. I have already installed and enabled that ...
0
votes
1answer
87 views

Bind bash script to keypress

How do I map a keypress on a keyboard to a bash script? For example, when I press the "Esc" key, the script is run. OS: XFCE Spin Fedora 19 ---- EDIT ---- I need to set this via the console. This ...
1
vote
0answers
103 views

IDE for Bash shell scripting on Ubuntu? [closed]

I'm probably looking for the Holy Grail here, but I figured I'd ask. Is there an IDE for Bash shell scripting on Ubuntu (Ubuntu 12.04 in my case)? Something with a code editor that lets you set ...
1
vote
1answer
35 views

Trim File Names of Tarballs Using Bash

I need to grade some source code from various students. The submission process is through Blackboard which appends to the file name a bunch of unnecessary stuff. Here is an example: Test ...
1
vote
1answer
85 views

Linux Bash “|” operator doesn't work - what am I doing wrong?

I am trying to check user password via login command like this: # echo "name\npassword" | login but the command ends without writing anything. echo ends because of SIGPIPE. Why did login stop ...
0
votes
1answer
37 views

find files older than create its parent folder in a directory and move them there

I've been trying to create a bash script that does the following. Use the find command to search for files older than 7 days (find . -type f -mtime +7 ! -iname '.*', take the parent directory(of the ...
0
votes
0answers
26 views

Vagrantfile - is rvm in ~/.rvm/scripts/rvm or ~/.rvm/bin/rvm?

I'm still learning my way around some of the more hidden files in terminal and I was trying to setup a Vagrant box with rails via shell script provisioning, with some help from these links: ...
1
vote
0answers
201 views

Postgresql query within a bash script

We are having an issue with a postgresql bash query. The output of the query from the bash script add's additional quotes around the date. Please can you help me fix it?! Script: #!/bin/sh ...
0
votes
1answer
39 views

Bash provide options and pass variable on choice

Trying to give an option to users of an installer to chose either "Development" or "Stable". By default the installer does "git checkout 1.1.0", but I'm turning 1.1.0 into $GIT_VERSION and trying to ...
1
vote
2answers
390 views

How do I get Linux commands and scripts to work on Cygwin?

I'm back with a follow up question. How do I get Linux commands to work on Cygwin? First I asked you what tool should I use to help me run my Linux scripts on Windows and you suggested Cygwin and I ...
0
votes
1answer
98 views

How do I run multiple scripts within a script, even if one script fails

I have a simple bash script that executes a number of other scripts … #/bin/bash … ./update_artifact1.sh $ARTIFACT_VERSION ./update_artifact2.sh $ARTIFACT_VERSION ./update_artifact3.sh ...
0
votes
0answers
80 views

automate drive mounting after Cisco AnyConnect client is connected

I have a request to write a bash script for clients to open VPN connection and automount remote drives. I am not sure how to approach it. I figured out I can use "vpncli.exe connect " to connect, but ...
0
votes
0answers
100 views

find files between dates and move to other directory

I have multiple logs file in one of the direcortories, was trying to move them monthly wise to another path. tried below script for the same. for Month in `seq -w 1 12`; do MLDAY=$(date -d ...
-1
votes
2answers
79 views

Execute a command for 3 lines at a time

I'm trying to run three separate processed while reading foo.txt Here is the example: cat foo.txt | while read line do echo line1 echo line2 echo line3 echo "" done The expected output is: line1 ...
8
votes
1answer
538 views

why doesn't a bash while loop exit when piping to terminated subcommand?

Why doesn't the command below exit? Rather than exit, the loop runs indefinitely. While I discovered this behavior using a more complex setup, the simplest form of the command reduces to the ...
0
votes
3answers
48 views

Newline in a for loop

How can i make a newline in a for loop in bash? I've tried echo -e but its not working. When i am opening a log file everything is on a single line. for i in */ ; do ...
0
votes
2answers
415 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 ...
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 ...
-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
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 ...
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 ...
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
145 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
56 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 ...
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/ ...
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 ...