1
vote
1answer
28 views

extract file content to mutliple files base on match pattern

I am new to unix. I would like to process this file. PP_NAME_1 jprovider|J Driver Provider|${J_DRIVER_PATH}/jcc;${J_DRIVER_PATH}/jcc_license_cu|${J_DRIVER_NATIVEPATH}|com.jcc.Connection ...
0
votes
1answer
31 views

How to use find to fill in variable in Shell script

I am making simple Shell script form some boring-ever-repeating job. Script changes directory correctly, and now I want to run other scripts based on argument I typed when running script. Other ...
1
vote
1answer
34 views

How do I identify shell script execution vs dot execution

I'm writing a bash script that needs to run on the current process for it to be useful. That is, I want to make sure that the script was invoked with source script.sh or . ./script.sh and not ...
3
votes
1answer
113 views

#!/bin/bash -e :: what is `-e`? other arguments?

I am a shell script coder that always opt to use shell as top level as part of my belt in creating website apps on the fly and have relied on my bash scripts if I want a project to be implemented ...
0
votes
1answer
63 views

input from shell in bash script

i have a bash script i would like modify to support input from shell atm i have to type the link after i have run the script wiak@test:~$ scripts/lget.sh gimme cookie! ...
1
vote
1answer
234 views

Creating a zip file with a timestamp

I have been trying to create a script which compresses a directory with a timestamp and move it to another location on the same server, but I cant seem to get TESTDATE to display on the zip file, ...
2
votes
3answers
106 views

How can I find folders containg x files of a particular type and output those paths on OSX

I have this script for OSX for finding folders that only contain one file, and if that file is an audio file outputting the path of the audio file find "$1" -type d -exec sh -c '[[ $(find "$0" ...
1
vote
3answers
210 views

Tool to record an interactive bash session to shell script

Is there a tool to record an interactive shell session to a shell script? For example if we entered in a terminal: interactive2sh reconfig_foo vim /etc/foo.cfg ibar^ESC:q /etc/init.d/foo restart ...
1
vote
0answers
200 views

find command with exec sh doesn't work in shell script but in commandline (raspberrypi)

I want to find "old" folders in /volume1/photo/ipcam which are named like "????-??-??" and move corresponding folders within dropbox (with the same directory structure /ipcam/...) to the subfolder ...
0
votes
0answers
108 views

Cygwin can't execute Shell script

I am trying to execute a Shell script using Cygwin. When I type this in the Cygwin terminal: sh build-native.sh I get this: build-native.sh: line 2: ndk-build: command not found It's a script ...
0
votes
1answer
110 views

Save session using shell command in KDE

I can save my KDE session using the KDE start menu. But how could I achieve to save my session by shell command ?
-1
votes
2answers
52 views

Is Dropbox a good place for my shell scripts? [closed]

I know the "official" place for my own shell scripts is the $HOME/bin folder. But i would like to use a Dropbox folder instead and then just simply append it to my $PATH. Something like ...
0
votes
1answer
63 views

Bash two text files comparision script

Given two files, I want to write a shell script that reads each line from file1 and checks if it is there in file2. If a line is not found in file2 it should keep it lets say in a table TAB1. Also, if ...
1
vote
3answers
245 views

Take all files in dir and for each file do the same perl procedure

I have dir, where are multiple files. a1, bb2, ccc3 At the moment I manually do: perl myperscitpt.pl a1 a1.txt perl myperscitpt.pl bb2 bb2.txt perl myperscitpt.pl ccc3 ccc3.txt How could I do ...
1
vote
1answer
836 views

Adding a month to an input date in unix

I need to write a script that asks user for an input date. Then I need to add a month to that date or at least 30 days. Example: Date: 2009-05-12 I need to get 2009-06-12 this code is not working: ...
0
votes
1answer
77 views

How do you determine if you're on a linux or BSD system inside a script?

I've got a rather extensive selection of dotfiles thats been kept in a git repo for the longest time - I just maintain a separate branch of code for bsd-isms (for instance, on Linux, to get colored ls ...
0
votes
1answer
92 views

Stopping command from terminal without stopping shell script that started that command

I have a script like this: #!/var/bin/bash tail -f /path/to/file.txt tail -f /path/to/other/file ... ` How can I stop tail -f without stopping whole script? Any idea?
1
vote
0answers
148 views

“Script” command in Bash on Mac OSX

quick question regarding the "script" command in Bash on a Mac OSX 10.8.4 system. In any other bash environment on Fedora, CentOS, etc; when I use the script command it just begins recording with no ...
0
votes
1answer
241 views

How can I both use and modify the history inside a bash script?

So I have the following bash script aliased as "fortunes": #!/bin/bash -i REPLY=; history -w /tmp/fortunes_history_backup; # save history ... history -c; # and clear it. while [ ! \( "$REPLY" = "q" ...
0
votes
1answer
101 views

Automatic autorestart Firefox on close

I want firefox to restart automatically when I close it. I found this script #! /bin/sh while [ true ]; do firefox done and I put a file with that script in the /etc/init.d folder. Firefox ...
3
votes
1answer
129 views

Using a shell script but it fails with spaces on directory or name

I'm relatively new to Linux script and I'm having an issue with one I'm trying to use when there are spaces in the directory name or file name. The script shrinks PDF files so that i can put them in ...
0
votes
2answers
168 views

Korn Shell .kshrc

I'm trying to make the UP arrow to get previous command in Korn Shell but I can't find .kshrc file in my $HOME directory. I know it is hidden but even ls -al doesn't show it. What should I do?
0
votes
1answer
178 views

What is the proper way to shell script a start / stop process that is triggered by another process?

Program 1 runs irregularly, and crashes program 2, which then crashes program 1. I'm not able to find the proper way to make program 2 stop when program 1 is initiated, and then restart program 2 ...
65
votes
6answers
4k views

How do I perform commands in another folder, without repeating the folder path?

Is there a clever way to do copy and move operations or a command to duplicate a file, without having to do a cd, then mv after, at the same folder? For example, I have to run the following: mv ...
1
vote
1answer
476 views

grep fails in upstart script

I have an upstart configuration for a service which needs to check the existance of a process on it's startup. This sounds fairly easy but I'm already trying for 3 hours to get this thing solved and ...
-5
votes
3answers
132 views

Shell script that reads a file and executes a command

I want to write a script which reads a file and executes a command for each row in the file. This command contains a variable for which we need to pass each row in the file. File has only one column ...
4
votes
2answers
1k views

How can I tell if OS X is connected to a VPN network from the command line?

How can I tell if OS X is connected to a VPN network from the command line? By running ifconfig without any arguments when I am connected, I see that there is a utun0 interface which appears to be ...
1
vote
2answers
452 views

Bash script executes but 'until' command not found

I'm writing a bash script for a class that has a main menu with two submenus. I haven't finished my script yet, but I already have a problem I haven't been able to remedy: My script runs fine but ...
1
vote
1answer
437 views

starting mongodb from a bash shell script

I am trying to start a mongodb using a cronjob+shell-script combo. In the shell, mongoDB starts when I enter $ mongod, however my executable shell script fails with mongod: command not found. I ...
1
vote
1answer
391 views

Shell Script : How use find expression in a for?

I would like to use the find command in a for. So I did this: for logs in `find $BACKUP_FOLDER -exec ls -la {} \; | awk '{ if ( $8==2011) printf $0"\n" }'`; do // some command here done; But it ...
0
votes
3answers
8k views

Linux Shell script to copy files from one location to another location

I have a folder in my server which contains some files. These are automated that means everyday we get new files automatically which will overwrite the old ones. So want to take a back up for this ...
1
vote
1answer
234 views

How to run a shell script on a Mac (10.7.4) to auto install updates?

Im trying to run this shell script that is supposed to do this: This script uses the softwareupdate program on OSX to automatically check for updates and install them. It also logs all updates to ...
0
votes
0answers
75 views

script on a remote machine that archive files fails

I have a simple script (Given below) on a machine that collect files from several folders into a single one and then archive it. The script works as expected on the remote machine. When I run it via ...
3
votes
2answers
124 views

Very Simple Script to Remove Last 5 Lines of a Series of Text Files

For some reason this script outputs three files for each original, rather than one. Must have made some trivial error - I'm new to this! Much obliged if anyone could explain why this happens. ...
0
votes
1answer
206 views

shell script : rsync exclude

I'm building a shell script and at some point I'm excecuting thie command : rsync -arv --delete --exclude=".svn,*.db,.DS_Store" Source/ Dest/ However it seems the my exclusion doesn't work. Am I ...
0
votes
0answers
93 views

Running different programs via ssh

I got some problem when I tried to run different programs via SSH. The problem is, let's say I have 2 different java programs, then I would like to run them simultaneously on different JVM, in order ...
1
vote
5answers
4k views

Running scripts from another directory

Quite often, the script I want to execute is not located in my current working directory and I don't really want to leave it. Is it a good practice to run scripts (BASH, Perl etc.) from another ...
0
votes
1answer
93 views

Problems with rsh

I have problems calling a remote command by different users on different machines. This remote command shall be executed on one single machine and the rsh-session shall be terminated immediately after ...
3
votes
1answer
159 views

Can't terminate a nohup process

I would like to send a SIGTERM signal to a nohup process, but this signal is completely ignored, only SIGKILL works, which is considered a bad choice to terminate a shell script. Do I have any options ...
0
votes
1answer
247 views

Is there a way to set settings/environment variables per terminal/bash - Linux?

I'm relatively new to using Linux and just recently had a very interesting request to assists testing at the company I work for. Testers tests application through terminal commands and separate which ...
4
votes
4answers
149 views

How to cut a file into pieces more efficiently?

Suppose I have a 10MB text file foo.txt, and it has 100,000 lines. Now, I want to process foo.txt window by window, with a window size 10. My current script is like this: for ...
0
votes
1answer
129 views

roll over stdout logfile (ash)

I'm wondering how I can make a logfile that records the stdout of a certain program to roll over when it has reached 500KB for example using /bin/ash as the shell? Thank you for any hints or ...
0
votes
4answers
2k views

How to recursively remove all .exe files from all the subdirectories of the current directory?

I have a USB containing important files. However it is infiltrated with some unwanted .exe files (probably virsuses) in each subfolder. Since I am on a Linux machine, the exe files won't affect me. ...
0
votes
1answer
141 views

move files/directories with similar names, matching rule

We were moving about 4TB of files to a Windows Server2 008R2 from a OS X Server. A lot of the filenames couldn't be moved because of incompatible characters. We ran a renaming tool to fix the problem ...
2
votes
1answer
313 views

Correct Method of Utilizing nohup in Batch Process

What would be the best method of using nohup in a batch script with multiple calls inside the script. For example, I have a script called filebuilder.sh and it contains something like: ...
2
votes
1answer
91 views

Using SSH, transfer webURL to remote machine

Hi so i was doing some research in the library so i could use some pictures later on my Desktop computer in my room. I have space on my Lab account which i usually SSH into, and i was wondering if ...
3
votes
3answers
720 views

How to check if zip file is empty in bash

How can I verify if the zip file is empty or not ? I cannot use if -s in bash as the zip file is not always zero in size. if the zip file has empty directories in it, I want to delete the file else ...
0
votes
1answer
538 views

how to convert line-delimited txt file into a spreadsheet file as tsv or xls

I have a huge amount of phone numbers (for example), one for each line in .txt file. 202898990 909090090 909090900 ... I want to put each number in a a cell (phone numbers in the same column). I ...
1
vote
2answers
2k views

Cron daemon running status check

I have a script which need to be run as cron job. In the staging environment i could run the script as a cronjob. but in the production environment it is not working, so i checked whether cron ...
3
votes
1answer
99 views

Creating a batch file to launch the currently opened applications and folders

Example: If I were viewing example.txt in a Notepad and editing an image in GIMP, I'd like to generate a batch file that would launch those files using those applications after I've closed the ...