0
votes
0answers
21 views

Getopts - command with multiple options

I have a command script i'm making and wondering how do i go about combining multiple options the general usage of the command is as follows: Usage: myCommand [-fpr] [-n count] [-s size] [-u user] ...
0
votes
2answers
30 views

Linux move files from specific directory one directory up and delete empty folder

I need to move files out from directory inside directory inside directory and remove folder that i move them from. I would need recursive script. Directory structure: ...
1
vote
1answer
48 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
1answer
39 views

Simple find and copy script for linux [closed]

I'm quite a newbie to scripts in Linux. What im trying to get is a simple script that finds a file by its exact name, then copy that file to a different folder. So Essentially it should work like ...
0
votes
0answers
33 views

Starting a Script with Nohup inside another Script

I have a server that runs several scripts, and every once in a while we receive an autogenerated alert mail saying that some are stopped. (It doesn't matter the reason.) Then we manually start all ...
0
votes
1answer
37 views

Create script to login and change time on unix Darwin

I work for a non-profit and recently had to take on some sysadmin responsibilities, and and it is a new area for me. We have a Apple X Server that is running Darwin, and from time to time, especially ...
1
vote
1answer
111 views

auto hotkey script to convert backward to forward slashes

Though I'm Windows based, I do my web development work in a customized console that mimics much of Unix particularities. One of these is that it uses forward slashes for paths, instead of backwards. ...
0
votes
1answer
45 views

Why is this awk statement not working?

awk 'BEGIN { COLM_FMT = "%-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s, %-8s,\n" } { printf COLM_FMT, ${totals[0]}, ${totals[1]}, ${totals[2]}, ...
1
vote
1answer
447 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
0answers
188 views

How to unwrap 80 character text

Many text filess around Internet are word split before line reaches 80th character. I understand it is desirable by those using 80 character terminals. However I like sending longer articles to my ...
0
votes
0answers
146 views

Running a Command in xterm Without the Window Closing

I am trying to figure out how to open an xterm and execute a command in the new window without the window closing. Ideally, I would like to be able to open an xterm, switch users, and source a .cshrc ...
0
votes
2answers
139 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
0answers
177 views

ImageMagick Script Error: ': No such file or directory @ error/blob.c/OpenBlob/2644

I am trying to run the following script in terminal: mogrify -resize 900x10000 *.JPG mogrify -resize 900x10000 *.jpg for f in *.JPG do echo "<tr><td><img ...
0
votes
1answer
160 views

Writing a tcsh script to copy files specified in first argument to a specific directory

I'm trying to write a script in tcsh that will copy select files that I specify at the command line from one directory to another without having to write out the entire path of each file. Also, to ...
0
votes
2answers
139 views

Writing Unix script (bash) that creates a directory in the location specified at the command line

I currently have a Unix script (written in bash) that executes several commands to modify a group of files, which I specify with an flist containing their paths. The general idea of the script is to ...
2
votes
1answer
77 views

bash function to write comments to a newly created file

Please see the following function — function touchm(){ date=$(date +'%Y-%m-%d %H:%M:%S') read Y M D h m s <<< ${date//[-: ]/ } file_name=$1 if [[ $file_name =~ ...
1
vote
2answers
312 views

Making Windows scripts run in Unix

IS there any way to make Windows scripts (BAT) files run on a Unix machine? Like importing a function or a library for example, which is only recognised on the Unix OS, but has no effect when run in ...
-4
votes
1answer
58 views

Syntax for Functions in Bash

I do know the JavaScript syntax: var functionName = function(some perameter){ some code here; }; but what is the syntax for a function in bash?
2
votes
3answers
1k views

How to test stability of wireless router

I had a wireless router that would intermittently drop connections, so I had switched to using a different router. I have since updated the firmware on the problematic router. Is there an easy way to ...
1
vote
2answers
3k views

Start script on logon

I understand shell executes commands in either ~/.bash_profile, ~/.bash_login or ~/.profile, whichever is found first. My system has only .profile, yet commands entered there won't get executed on ...
0
votes
2answers
135 views

Shell script: Copy folder with a new name

I'm trying to write this shell script to create in the parent directory a copy of the folders found in the current directory. So far, I wrote this: for folder in *; do mkdir ../$folder; done ...
3
votes
1answer
132 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 ...
2
votes
1answer
221 views

Run script when shutting down Ubuntu before the logged in user is logged out

I'm writing a script to backup some local directories on a Unix machine (Ubuntu) to a Samba drive. The script works fine and I've got it running at shutdown and restart using the method described at ...
0
votes
1answer
98 views

Can not understand this script

Can someone help me understand this script? It is from sysconf_add and I am new to scripting. I need to do something similar. function add_word() { local word=$1 local word_quoted=$2 ...
2
votes
1answer
89 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 ...
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 ...
0
votes
2answers
64 views

How to calculate a column of sums or test inequalities?

Given 34-2 34-5 34-3 I'm looking to obtain 34-2=28 34-5=29 34-3=31 Or, this would also be helpful: given: 34-2=5 34-5<=34 34-3=31 I'm looking to obtain ! 34-2=5 34-5<=34 ...
0
votes
1answer
234 views

Should we systematically use `--` when executing `rm`?

A question about the recommended usage of rm and -- Let's say I've created two files -i and xx. If I try to remove them with $ rm * I get: rm: remove regular file `xx'? n And, as explained in ...
0
votes
2answers
608 views

How to get the current timestamp when using 'ps' in a Bash script?

I am writing a shell script that gets all the current processes running, and pipes them into grep to filter out the ones I need. But I also need it to give me a timestamp, either when the ps occurs, ...
0
votes
2answers
287 views

Is it possible to add an exception with a “ls -l *”

Is it possible to do for exemple: ls -l * which print the content of all a directory. And add an exception, for exemple, test.cpp In order to print all files except the test.cpp.
7
votes
6answers
2k views

Best practices to alias the rm command and make it safer

Some time ago I erroneously deleted my home folder because I ran a rm -rf * on the wrong terminal, whose working directory was the home folder! I wish I had an alias for the rm command, but it was ...
3
votes
4answers
5k views

How to append a string to a file name in Bash Shell?

So I am supposed to find all the files in the given directory with surffix of .C or cc, and change their name to .C.blah or .cc.blah Is there a command to do that? Or should I implement this with ...
-2
votes
2answers
377 views

Shell script error using command find

My script is supposed to: recursively look for files and directories whose names contain given strings, using find, starting in the current directory. If no arguments are given the message Missing ...
0
votes
1answer
155 views

How to write a script that does what less does?

Question: Create a script such that it is a command that has the same effect as the "less" command (implement the script by calling "less"). What I wrote: #! /bin/bash for index in "$@" do less ...
1
vote
1answer
143 views

Identifying a file with “file” in a shell script?

I'm currently writing a shell script that needs to be able to identify the actual type of files (not their extensions) with the unix "file" utility. However, that tool outputs human readable text ...
-1
votes
2answers
1k views

How do I create a wake up script using PowerShell? [duplicate]

Possible Duplicate: Alarm clock software that can turn the computer on? I need something that can wake someone up in the morning - basically like a cron event in Linux. I think this needs ...
2
votes
1answer
104 views

When I use sudo to run a command, aren't the environment variables visible?

$cat test export var=value $source ./test $cat print.sh echo $var $chmod +x print.sh $echo $var value $sudo ./print.sh I get nothing. I was expecting to see value. What is going on?
0
votes
1answer
3k views

House keeping removing 30+ days old files using shell script

So I have to bit of housekeeping for old backups and have the following code working on sh: find /home/backups -mtime +30 -type f -exec rm -rf {} \; This works fine as know the location/path, so ...
2
votes
3answers
274 views

SSH registration script

Could anyone write or help me write a bash script that would do the fallowing: New user connects to my FreeBSD server and log-ins via SSH with certain credentials like 'user registration, pass ...
6
votes
1answer
2k views

How can I generate Pi to a given number of decimal places from a script?

Does anybody have a script that I could easily run like: sh generatepi.sh 10000 where 10000 is the number of generated π (Pi) decimal places.
2
votes
1answer
1k views

How can I (on Mac/Unix/Linux/scripting) recursively copy a directory into another and replace only the files that have not changed?

Background and issue I moved to Mac OS X recently and bumped into the "feature" of Mac where copying files from an external drive resets the file modification/update date/timestamp to the current ...
1
vote
1answer
130 views

Best way to iterate through a bunch of files and search/replace text?

I'm having some trouble doing something that should be fairly simple. Here is how I imagine it would work: find . -name *.txt -exec sed 's/oldtext/newtext/g' {} > tmp \\; mv tmp {} \; ...
2
votes
2answers
355 views

How can I set up an alias or shortcut to do the *nix find command?

When at the command line, I find that I have to type out this command very often: find . -iname "*php" -exec grep -H query {} \; I'd love to set up an alias, script, or shortcut to make it work ...
1
vote
4answers
195 views

What does this line of shell script do?

ls "${VMX_DIR}" | grep -q delta > /dev/null 2>&1; It lists the files in VMX_DIR and then pipes them into grep but what is it doing?
0
votes
2answers
204 views

how to change the existing printed line in AWK

when i execute the following line, its prints the words in newline. awk 'BEGIN { print "line one\nline two\nline three" }' like line one line two line three How can i print the info in the same ...
4
votes
2answers
266 views

Use of '#!' in *nix scripts

In many Apple/Unix scripts I see stuff preceeded by '#" which as far as I know means it is a remark. However often you see shell calls as below (the line with #!). ## Setting a default route ...
0
votes
3answers
4k views

Avoid printing line breaks in shell script

while read pos; do string1=`echo $pos | cut -c 20-38` string2="=$pos" string3="$string1 $string2" echo "$string3" done < file This is the code of my script. I want to ...
0
votes
4answers
183 views

Unix script: use of date and use of for

MinuteNow=date +%M; for ((i=2;i<=57;i+=5)) do if [ "$MinuteNow" == "$i" ]; then ************* fi done The problem is for 2 and 7, the date commande output is 02 ...
1
vote
2answers
124 views

terminate the background task launched by xterminal

I used Xterm -e command to run six programs in the background in six X terminals in my shell script. When I used PS command, I can see 6 Xterm process running in the background but I can't see the ...
6
votes
4answers
15k views

How do I compare two files with a shell 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 it should output two files are different and exit. The files ...