Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

1
vote
3answers
45 views

Pulling Lines X-Y From List of Files Found

Ultimately I need to grab lines 3-53 from ever csv in each subdirectory. I grabbed the lines like so (cat isn't necessarily required): cat /[path]/[file].csv | head -53 | tail -51 And the files ...
0
votes
0answers
20 views

Bash script for opening screens and compiling the same file

I have written a bash script to initiate separate screen sessions and run a command in each of them that compiles the same C++ source file in ROOT (an object-oriented data analysis framework ...
0
votes
0answers
6 views

How to use scanner drivers api in Linux shell script

Usually when scanning any page using Canon DR- 2050C scanner in windows it rotates vertical text paged to horizontal automatically for the easy reading of the user. In Linux we are manually scanning ...
1
vote
4answers
150 views

How can the following script be explained?

Code: #!/bin/csh if ( A$1 == A ) then echo "" echo "LIST <name>" echo "" exit endif .............. Ok this is a sample from a bigger script I got. The scripts starts with ...
0
votes
0answers
14 views

Run Xserver as root

I am working with an ARMStone a9 board which has iMX6 linux kernel. I am doing an embedded application in which I have to show a video from Ipcamera. The thing is that I attached the screen to my ...
0
votes
0answers
22 views

get time of file in inotifywait tool

for this script: inotifywait -m /path -e create -e moved_to | while read path action file; do echo "The file '$file' appeared in directory '$path' via '$action'" # do something with the ...
1
vote
1answer
23 views

TCL script try catch

I have a TCL script that sets a number of variables and reads several files. The last file it reads may contain sensitive information, so I need to make sure this file gets deleted even if an error ...
-2
votes
2answers
35 views

Unix AWK command with multiple field seperators [on hold]

I faced a problem with awk where my field separator has multiple characters. I have found the solution but I am unable to understand the script. awk 'BEGIN{FS="[char1][char2][char3]+";} This is how ...
3
votes
2answers
67 views

Loop in WildCard as Input of Script

I want to use my script on many files sometimes. I used this for the purpose: for etminput in $1 do #process done But this just gives the first input. How can I do the process on every ...
1
vote
2answers
26 views

Livesearch with first 10 matches as preview for zsh-history?

I have seen a history-livesearch with a preview, that shows the 10 first matches in the history in a list below the BUFFER-line, which is updated on every keystroke, and acts like the standard ctrl+r ...
2
votes
0answers
12 views

unbuffer/expect swallows the rcode when its child is signaled

unbuffer is able to pass along the return code of a process under normal circumstance, but if the process you are unbuffering is killed, for instance with a segfault, I see $? as 0 while I expect 139. ...
1
vote
2answers
16 views

Querying a remote POP3 Mail server using BASH

I'd like to connect to our mail server via POP3, look for a certain pass phrase in the subject and if found then run a script. How can I achieve this with BASH other than awkwardly scripting Telnet? ...
-4
votes
1answer
37 views

unix (batch file ) [on hold]

Create one unix script, where a)Take name of file as input from user and create file with same name. b)in file write 10 lines of text and save it. c)search a string given by user, search that ...
4
votes
1answer
44 views

Bash script for scp interpreting tilde (~) too soon

So, I just started a new C++ class that requires me to program in a Linux environment. I don't have Linux installed on my machine, but I do have OS X and I can ssh into a linux machine in the lab at ...
0
votes
1answer
15 views

Header about MIME email

Morning, can some body help me about MIME email? I want to send HTML email like this: MIME-Version: 1.0 Content-type: multipart/alternative; boundary=lazuardi --lazuardi After that email. I have ...
0
votes
1answer
41 views

Is there a way to create a new file and insert text into this file all with bash? [on hold]

I need to change and create several configuration files for some kiosks at work, is there a way to do this with a single bash script? I've heard about SED but the documentation is confusing, could ...
2
votes
2answers
69 views

find file, copy but with different name

I have files with random numbers in /home/user/files folder (every 4 days I have new ones). for example: john20 john25 john40 tom12 tom32 simon2 simon8 simon53 I want to take only last modified ...
0
votes
2answers
67 views

Intro to shell scripts with basic application: how do I set my computer to make an archive of a particular folder every day?

I've got a situation where I need to give some people access to my dropbox folder. Already so far they have deleted huge folders full of important data. Their computer skills could use a bit of ...
0
votes
0answers
31 views

How to remove files except a list with names files [duplicate]

I need delete some .desktop files in various directories and a text file with a list of file names. I want to delete all these .desktop files except for those listed in my text file). Example $ ls ...
0
votes
0answers
20 views

startx & screen goes off [on hold]

I am working with graphical in a Linux linaro in a embedded system, and I use the startx & command for run it. My problem is that after 10 minutes more or less, my screen is goes off. I guess ...
2
votes
1answer
57 views

Login automatically as root

I am working with a board and when it finishes the boot, appears the login. What I want to do is login as root but automatically. I mean I want to do that when boot is finish, I can see the prompt, ...
1
vote
0answers
21 views

Run startx & automatically embedded syste,

I am working with a board in which I run my application which use th graphical mode. Everything works perfect. I start the graphical mode like this: startx & and then I run my application like ...
-3
votes
0answers
46 views

please let me know where to attach the files here? [closed]

Below is the requirement. Ignore lines containing pattern "SET SNAP_ID" or "Shadow Copy Components:\" . Ignore lines with column 2 till 8 is empty. print lines containing pattern "Failed". ...
0
votes
2answers
30 views

How to pass argument with spaces to a shell script function? [duplicate]

I'm trying to pass multiple argument to a function, but one of them is consist of two words and I want shell function to deal with it as one arg: args=("$@") function(){ echo ${args[0]} echo ...
2
votes
3answers
64 views

Script to ssh and run a command doesn't work

Below is the script. I wanted to login several servers and check for the kernel version. #!/bin/bash #input server names line by line in server.txt cat server.txt | while read line do sshpass -p ...
2
votes
1answer
16 views

ionCube shell script gives error

I have this shell script to install ionCube loader: if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi echo "Welcome to this script to install the ionCube loader on CentOS!" cd ...
3
votes
1answer
51 views

Tokenize string from $REPLY in bash script

This is my first post, and I have no idea how I managed anything before StackExchage, Google, Wiki, GNU, Internet, the list goes on :) I am trying to find a way to construct a SQL database generator ...
2
votes
1answer
18 views

Comparison of columns in two files and appending the first file

I need a help on this :- I have a file : emp.txt 21356 suresh 12/12/2012 23511 ramesh 11/06/2011 31456 biswajit 09/08/2013 53134 archan 06/02/2009 first field:- employee id, 2nd field is name and ...
3
votes
1answer
25 views

Service script calls another script with variables

I have a simple service script tomcat7 in /etc/init.d/ to start and stop my app server (tomcat) under the tomcat user. On RHEL6. #!/bin/bash # description: Tomcat Start Stop # processname: tomcat # ...
3
votes
5answers
151 views

efficient cross-os file size shell function

I'm looking for a simpler way to have a cross-os-unix file size check. I could use wc -c but I'm concerned the performance may suck on large files (I'm assuming it just counts chars and doesn't do a ...
1
vote
3answers
114 views

Calling a function which calls another function with a for loop

I am calling a function with a for loop and saving the returned value to a variable. When I run the code, I get a command not found error. What is wrong? #!/bin/bash check_1() { x_$1=$(check_2 ...
0
votes
1answer
9 views

Cannot access elements of an array in zsh

I am trying to write a script in zsh and I need to make use of arrays in order to achieve my aim in an elegant way. After reading some information over the Net, I tried to implement and access the ...
3
votes
1answer
158 views

How do I fill my password automatically from .bash_profile when running command as sudo?

I know I could just put something like sudo mypassword in my .bash_profile, but I don't want to run every command as root. I want password to autofill under following circumstances: only the ...
3
votes
2answers
34 views

Problem with read variable from AWK

I'm trying to get memory info by this command: #!/bin/bash set -x cat /proc/meminfo | grep "MemFree" | tail -n 1 | awk '{ print $2 $4 }' | read numA numB echo $numA I'm getting this + awk '{ print ...
3
votes
1answer
34 views

Error when calling a script from inside another script

I'm writing a couple of scripts to start vlc and periodically update its playlist. The update_pls.sh works well if I execute it from prompt, but when I call it from start_vlc.sh, in each for cycle I ...
4
votes
3answers
133 views

Running commands on multiple servers [duplicate]

I want to execute a process on multiple servers. I am using the following wrapper script. The script moves to servers one at a time. I would like to change it so it can execute on multiple servers. ...
2
votes
0answers
75 views

How to write a shell script to run multiple command in different screen sessions?

My goal is to write a zsh script in order to create multiple screen sessions and run separate commands on each of them. I would also like to check at the beginning of my script if there are any ...
1
vote
2answers
62 views

I get a “command not found” error, though the script file is shown by “ls”

I want to run yii console commands in shell. I run protected/yiic in the console, yet it fails, yielding -bash: yiic: command not found What's the problem? See the shell commands and responses I ...
-2
votes
0answers
42 views

Unix date difference

I am getting error for this script can any one help for this one #!/bin/bash echo enter first time stamp read d1_1 d1_2 echo enter second time stamp read d2_1 d2_2 secdiff=$(( $(date -d "$d2_1 $d2_2" ...
0
votes
0answers
16 views

AWS EMR Bootstrap

I need to write a bootstrap action file for my AWS EMR that runs during provisioning and performs: Install latest R version from: http://cran.us.r-project.org Install ‘lme4’ package (and all of its ...
0
votes
2answers
73 views

How to kill a process running in specific script

I have two script files running simultaneously. I just need to kill the java process running in one script without affecting the java process in the another one.
0
votes
0answers
13 views

Mutt multi content type

Good afternoon I want to send multiple content_type with mutt. Can I do that? Here is my code : mutt -e "set content_type=text/html" -e "set content_type=text/plain" someone@mail.com -s "Multi ...
2
votes
2answers
124 views

to compare two fields in two different files

In file1, I have 1023M BLD 123G DEV 945K Deployment 4899 INT In file2, I have 1.2G BLD 123G DEV 345M Deployment 499M INT I wanted to compare the first field of file1 with first ...
1
vote
1answer
33 views

How could i flip content of a binary file with bash commands

I was wondering if it's possible to do bitwise conversion on a binary file, with bash commands, (in my case bitwise negation).
0
votes
2answers
40 views

init.d script is not starting under virtualbox

The script is in /etc/init.d: #!/bin/bash VMUSER=myname CURRDATE=(`date +"%m-%d-%Y"` + `date +"%H:%M:%S"`) CURRTIME=(`date +"%X"`) FILE=/home/myname/log/vm-services.log VBPATH=/usr/bin start(){ ...
0
votes
1answer
53 views

Problems copying files with spaces inside the file name in a bash script [duplicate]

I have the following function inside a BASH script (running under Ubuntu 12.x), which would copy over a file with spaces inside the file name. It's not working. I've tried many different combinations, ...
2
votes
1answer
37 views

Killing multiple instances of the script from the script itself

I've couple instances of script.sh running in parallel, doing the same thing, running in background. I'm trying to use a function to kill all the current running scripts when executed. So, for ...
1
vote
1answer
59 views

Why doesn't this piped script work?

#!/bin/bash rm out mkfifo out nc -l 8080 < out | while read line do echo hello > out echo $line done If I browse to the IP of the machine this script is running on (using port ...
5
votes
4answers
425 views

How can I “lazily” read output from xrandr?

I have a bash script that I use to adjust my monitor brightness that uses xrandr --verbose to get the current brightness. It works fine, but using xrandr is kind of slow on my machine, as you can see ...
1
vote
1answer
72 views

Command-line parameters in bash script not recognised

I use Debian (Raspbian) Wheezy. If this command line works fine: smsd -c sms/out -i 60 -0 -f sms/smsd.log and this alias also works fine: bsmsd='smsd -c sms/out -i 60 -0 -f sms/smsd.log' then ...