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

learn more… | top users | synonyms (2)

0
votes
0answers
28 views

paste command puts result on separate lines, instead of columns on the same line

I was trying to copy different files in to one using paste data_{1..2}.txt > 1_2.txt or paste <(awk '{print $1}' data_2.txt ) <(awk '{print $1}' data_2.txt) > 1_2.txt Both of them ...
1
vote
2answers
32 views

Using sed with herestring (<<<) and read -a

I use sed with <<< and read to assign all words in a string to variables. What I do is: read -a A0 <<< $(sed '2q;d' /proc/stat) Hence, sed reads the second line of the file file ...
2
votes
1answer
31 views

Storing whitespace in a shell script variable [duplicate]

I need to store specific number of spaces in a variable. I have tried this: i=0 result="" space() { n=$1 i=0 while [[ "$i" != $n ]] do result="$result " ((i+=1)) ...
-2
votes
1answer
25 views

how to pass enter character to other shell script [on hold]

One script needs enter key to proceed. Other file should send the key. I will run the command like below: sh scriptfile < file
0
votes
2answers
24 views

Searching out a pattern from Logs

The format of the logs is in this manner: Junk Junk Junk : Junk Junk Junk:IP/Port Junk Junk I want to search using the IP and the output should be only the IP/Port part of each line in that log ...
0
votes
1answer
32 views

How to start several jobs in different screen sessions in a Bash-script?

The programm I want use can be started via ./myprogram < input_part1.txt > output_part1.txt How can I start four jobs of myporgram in a BASH-script where each job runs in a separate ...
1
vote
1answer
24 views

Global variable for every script

I want to declare a variable in such way that every script can access and alter its value. I have written a script that set the value of a variable called flag on exit and I am using a crontab entry ...
0
votes
0answers
23 views

Zsh script cannot find screens

I have created a zsh script launching many screens in detached mode with particular names and running particular processes in them in order to automate some data analysis in high energy physics. ...
0
votes
1answer
22 views

Zsh script how to concatanate array elements with string

I have written a zsh script to automize an analysis in high energy physics and now I would like to use an element of the one of the defined array some string and another element of some another array ...
2
votes
1answer
98 views

How to print a bash variable that has an array as value

I wrote a script for my dwm statusbar. One part of it is finding the current cpu usage for every single core on my system. I figured out a way myself but I would need some help fixing a bug in this. ...
2
votes
3answers
100 views

How to get cpu usage for every core with a bash script

I'm writing a bash script to print system stats to my dwm status bar using xsetroot. Everything works as expected. What I'm currently missing is an easy way that just uses standard *nix tools to give ...
1
vote
1answer
29 views

How to ensure a bash script is executable via web without being in /cgi-bin directory?

My document root is /0/ i do not have any cgi-bin directories. this is my virtual host with apache: Listen *:80 DirectoryIndex 1 <VirtualHost *:80> DocumentRoot /0 ServerName domain.tld ...
1
vote
1answer
202 views

What does this `cat` statement do?

I'm new to Linux and trying to figure out what this statement in a Bash file does. I think it combines stdout, stderr and output it to the file $log is pointing to and append the multiline string to ...
1
vote
2answers
38 views

Search for a string in the output of a command

I'm stuck with a simple script. I want to run tracepath on multiple address and to find if some IP is contained in the output of the tracepath. For now I have the following: if tracepath -n ...
1
vote
1answer
34 views

How to extract values from a file using pattern(s) from a column in another file, and insert such values as a new column to the latter?

I sample "winning" sets of 60 game cards such as this one and extract the card names and count and format it for use with some software. The output format is: ...
2
votes
2answers
32 views

Sed find and replace with slashes

I am having trouble using sed find/replace with slashes in the find parameter. Sample contents of test.sh str=$(sed -n '/^user:/p' /tmp/shadowtest) # find "user:" line in /etc/shadowtest ...
1
vote
3answers
47 views

Bash script in ( set -x ) mode does not display what “cat” command does. ( contents of it )

in this bash script.. it simply shows.. +cat as it runs. #!/bin/bash set -x cat > /test << "EOF" a b c d EOF but i rather show everything that it does . including the a b c d ...
0
votes
1answer
41 views

Running shell script on cluster in parralel

I thought dsh(Distributed Shel) will be a good option but when i ran my shell script across my nodes, I didnt get expected output, dsh -aM -c bash /home/cloudera/bash_script.sh server2@x.x.x.110: ...
0
votes
0answers
33 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
8 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
163 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
23 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
27 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
27 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
45 views

Unix AWK command with multiple field seperators [closed]

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
72 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
29 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
13 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
19 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
41 views

unix (batch file ) [closed]

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
56 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
17 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? [closed]

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
76 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
68 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
22 views

startx & screen goes off [closed]

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 ...
3
votes
1answer
79 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
22 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 ...
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
73 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
19 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
73 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
26 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
156 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
116 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
165 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 ...