A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (1)

0
votes
1answer
137 views

How to reassign new values to array elements?

I'm trying to figure out like three or four things at the same time.The most I need help with is how to get the greatest number in all the files that I have created on a prior run of my script, that ...
4
votes
4answers
350 views

How can I suppress output from grep, so that it only returns the exit status?

I have the grep command. I'm searching for a keyword from a file, but I don't want to display the match. I just want to know the exit status of the grep.
4
votes
3answers
117 views

Bash: handling “[[ statement ]] || echo problem found ; exit 1” logic

In the statement in the title, there is a problem that even if the statement is true, it will still exit with status 1 because, as I understand it: [[ statement ]] || echo problem found ; exit 1 ...
1
vote
0answers
38 views

List Mails by subject

I'm writing a script to send mails from a mailbox on a remote server and a script to check if the mails are received at another remote server. For this I have configured mutt. What I now need is to ...
1
vote
2answers
58 views

Command working from CLI but not from script

I have a command that I use from the CLI to properly color files, folders, executables, etc. The command that I'm executing looks like this: test -r ~/.dircolors && eval "$(dircolors -b ...
1
vote
4answers
443 views

How do I delete files with spaces in them in bash script?

this is a three part topic to a two part process that still is not working for me: Objective: to manipulate a filename then delete it the filename has spaces between the words then the dot .ext ...
2
votes
1answer
553 views

Using BASH versus ASH on Synology

The majority of my photo files have the following naming convention / format IMG_20131204_120000.JPG, showing date and time the photo was taken (iPhone/Apple naming convention). However, not all my ...
5
votes
5answers
512 views

Parsing a delimited text file in bash as command arguments

I have a text file split up like so: field1,field2,field3 xield1,xield2,xield3 dield1,dield2,dield3 gield1,gield2,gield3 Each of these columns will be a parameter to a program, and I would like ...
1
vote
3answers
94 views

Automating pipes?

I find myself using basically the same line over and over again: cat file | command1 | command2 | command3 > file Is there a way I can put all these pipes into one script, so I can just run ...
2
votes
1answer
34 views

Why does combining `less` and `script` disrupt line endings?

This bash snippet will print out the numbers 1 to 10: $ for i in $(seq 1 10); do echo $i; done 1 2 3 4 5 6 7 8 9 10 When I try to use this with script and less like so: $ script -q -c 'for i in ...
3
votes
1answer
40 views

How to maximize a window programmably in X Window?

I'm wondering if there is any commands or programs to make some window maximized in X Window? For example, what I imagine is something like this xmaximize -window *window_id*
1
vote
1answer
158 views

script to automate scp in network

I have a network full of Linux machines. In this network, I have a user as user1 with the password as password in all the machines. I have the following script to put files in the home directory of ...
3
votes
3answers
77 views

Collect EXIF data of a directory

Is there a way to extract EXIF information of all images within a directory (into an output file)? Preferably I also need GPS data but this is not essential. I only ask, as I have a number of ...
4
votes
1answer
171 views

remove title bar of another program

I have developed a program with glut library and want to remove its title bar. Since its impossible to remove the title bar from glut library I have to use an external tool to remove its title bar. ...
1
vote
1answer
137 views

Cannot locate libncurses.so location when running a file

I'm trying to run a file name remote build which is to build a package on a target server. My target server is HP-UX-itanium 64 bit. When I run the remote build, somehow it cannot find libncurses.so ...
-1
votes
2answers
123 views

Shell script passing null value while executed as cron job [closed]

We are using the below commands to get pagesapce values and I need to check percent of used pagespace. For this I have used the below code, but when running this script it's passing a null value into ...
4
votes
2answers
91 views

Create sub-directories and organize files by date from file name

I have been using the following script to organize my photos into "Date' Directories: for x in *.JPG; do d=$(date -r "$x" +%Y-%m-%d) mkdir -p "$d" mv -- "$x" "$d/" done This script works ...
2
votes
2answers
244 views

Bash: append columns to table

If you want to append a column (not a line) to a table, and the column has the same number of elements for sure, how can you do it? Given a set of files, which keeps changing each day, you want to ...
2
votes
2answers
96 views

Join two files with different number of columns and rows

I have two files. file_1.txt looks like this: R1 C1 C2 C3 C4 C5 R2 C1 C2 C3 C4 C5 R3 C1 C2 C3 C4 C5 R4 C1 C2 C3 C4 C5 ...
1
vote
4answers
73 views

play mp3 file as soon as its downloaded

How do you combine these two different commands into one script: $ wget http://mymusic.store.com/musicfoo.mp3 #file gets saved as musicfoo.mp3 $ mplayer musicfoo.mp3 wget attempts to save the file ...
2
votes
3answers
167 views

How to compress and transfer folders from one server to another over network

Do we have any option to transfer folder from one server to another, that is faster and compressible and bandwidth limit settable method? The servers run on Linux. I tried tar + ssh but I couldn't ...
2
votes
2answers
115 views

stripping out the last two [end] with sed?

I'm working on a script that improves the fluxbox 'menu', and my script has this line: sed -i 's/\[end]//g' ~/.fluxbox/menu;sed -i '/^\s*$/d' ~/.fluxbox/menu but this has the unfortunate effect of ...
1
vote
2answers
44 views

Keep only first match from locate output

I need to locate a library on my system and it's name is expected to be found a couple of times. I want to keep only the first occurrence. So far I've tried some methods for splitting strings by ...
-1
votes
1answer
51 views

find not working right

if [[ "$1" == "" ]] then leftarray=($(find . -type l -printf "%p\n" 2>/dev/null)) rightarray=($(find . -type l -printf "%l\n" 2>/dev/null)) for var in "${rightarray[@]}" do ...
3
votes
3answers
73 views

Script is stuck saying 1 response with 2 available: Math related

I have a script that tells the user the square footage of 2 rooms based on user input. I think I have that part done right. The problem I have is that I need to have the script say which room is ...
1
vote
2answers
618 views

Check a range of IP addresses to see if a host is active

I need to write a bash shell script that will check a range of IP addresses to see if a host is “alive” at that address.I also need to list the IP numbers of those that are “alive”, and provide a ...
0
votes
1answer
37 views

KSH conventions scripting [closed]

I'm writing scripts in ksh atm. I'd like to know if there is any "conventions" as for example, always doing "unset" before using a variable, or using typeset to define a new variable, etc.
1
vote
1answer
105 views

Changing the current directory using a script (ksh)

I'm launching my script from echo $PWD ---> /x. I want my script to change my current directory. So my script contains +- this : cd /y exit 0 However, when my script ends, I'm stils in echo $PWD ...
0
votes
1answer
27 views

Using variable in KSH function

I tried to have a switch if either an option is set or not while getopts "s:u:d:e:ch" _OPTION; do case $_OPTION in ... c) isCSet="Y" then I'm ...
1
vote
1answer
98 views

Automount post-unmount script

My intention is to spin-down an external USB drive after 20 minutes of not being used. In the normal case I would use hdparm for this but unfortunately this doesn't work on my external USB drive. It ...
0
votes
1answer
97 views

Using alias in another script (ksh)

I'm writing a ksh script, and I'd like to use a command define by an alias in my .profile file, in my script. I tried this command in the folder containing my script, and it works. However, in my ...
0
votes
3answers
56 views

Ksh script warnings [closed]

While running my script, I got the following message (it's not an error strictly speaking, because the execution go ahead after) : myScript -s test -u test2 pk_copylogs[2]: hist: :: not found ...
2
votes
4answers
216 views

How to use wc and piping to find how many files and directories are in a certain directory?

How can I use word counter and piping to count how many files or directories are in /usr/bin directory?
3
votes
2answers
128 views

vim: Execute BundleInstall without showing the vim interface

I have a installation script that I use to initalize my vim plugins when I'm on a new machine #!/bin/bash # Clone vundle into the directory if it's not already if [[ ! -e bundle/vundle/.git ]] then ...
1
vote
4answers
144 views

Is there a difference between ./script and bash script?

Given a shell script file that begins as #!/bin/bash # (bash script here), and has been chmod +xed, is there any difference in running ./script and bash script from the command-line?
1
vote
2answers
94 views

Is it possible to control xterm (or specifically a process that xterm has started) from another process?

If I start a process with xterm like this (where omxplayer is the process xterm is starting): xterm -fullscreen -fg black -bg black -e omxplayer -o hdmi -r %f Is it possible for me to write to ...
4
votes
3answers
67 views

Fast access to often used document

For several applications I maintain my personal cheatsheets. I use them mostly for vim, latex, vim latex-suite and bash. For example, when I forget a key combination in vim, I browse to the ...
1
vote
1answer
163 views

How do I track down the source of a ssh login message?

I installed mailutils on my linux machine with Linux Mint 15 (basically Ubuntu 13.04). When I log in, I get the following: Welcome to Linux Mint 15 Olivia (GNU/Linux 3.8.0-32-generic i686) Welcome ...
2
votes
3answers
84 views

What is the language that appears on the first line of a script? [duplicate]

Bash scripts start with the following line #!/bin/bash # Rest of script below ... In bash the # character is the start of a comment, but #!/bin/bash is definitely not a comment, therefore it isn't ...
0
votes
1answer
113 views

Why does a working standalone nested function/script not work inside a larger script? [duplicate]

The following (nested) function/s function hpf_matrix { # Positional Parameters Matrix_Dimension="${1}" Center_Cell_Value="${2}" # Define the cell value(s) function hpf_cell_value { ...
4
votes
4answers
142 views

Clean way to temporarily replace a config file?

I use a drawing program called Inkscape, which has both a GUI and a command line interface. When used on the command line, it has a large number of options that can only be controlled through a ...
1
vote
2answers
50 views

copy a section of data from stdin [closed]

I am running a script that takes its input from stdin. This input can end up being very large so I want to extract the part I'm interested in to a temp file. The first line contains "[cics]" and I ...
1
vote
2answers
184 views

How do I trigger a script when a folder is updated in Solaris 5.10?

We are trying to write a script to move away files as soon as they drop in a folder. One way of achieving this is running rsync in a script on cron scheduler. The problem with this approach is the ...
2
votes
1answer
96 views

shell script to append ID for newusers command

I am in the process of creating 60 users locally in a linux machine. I wanted to do it automatically and so I found I can use the newusers command to add the users in batch. I have the users and ...
3
votes
2answers
33 views

Overriding amended time stamps

I need to make it so the files in current directory get amended with a timestamp. It works fine for the first time, but once I run it again it adds another timestamp to the file. I need a way to ...
1
vote
2answers
241 views

Need to copy files to existing directory and remove files already there with the same name but different extension

EDIT: Total rewrite of question for clarity. I have a directory tree (new) with a bunch of files of with an extension of .new. I have an identical tree (old) where many of the files have names ...
1
vote
2answers
914 views

integer expression expected bash

Trying to loop a phrase inputted by the user a set amount of times that is also inputted by the user. Keep on getting the error integer expression expected, and I can't figure out how to fix it. ...
1
vote
1answer
37 views

Grep expression with special file names

I have to go through some regular files in directories and find those files, that have their own name in its content. In the following piece of script is a cycle in which I am going through paths ...
3
votes
1answer
138 views

Script to find the default Desktop Environment?

Assume a Linux Desktop Environment system is installed. When powered on and credentials entered, whatever Desktop Environment is started i would consider the default Desktop Environment. The user may ...
3
votes
1answer
216 views

Why is expect's interact command not working?

I am trying to automate gdb with expect. My script will start gdb, do some initialisation, and then pass the control to the user. Expect's interact command seems like the perfect tool for the job. ...