-1
votes
0answers
35 views

Append files with bash one-liner? [migrated]

Currently I use multiple lines to append content into a combined file, e.g. ./myprogram 1.txt > Out.txt # Overwrite for the 1st file ./myprogram 2.txt >> Out.txt ./myprogram 3.txt >> ...
0
votes
1answer
36 views

Bash function hangs while command run perfectly without function

Following function hangs : ssh() { local RESULTS; RESULTS=$(ssh $USERNAME@$SERVER $SSH_COMMAND1); echo $RESULTS; } ssh; while if i run following commands they work fine : ...
1
vote
1answer
74 views

Replacing LineFeed \x0a with SED

I have to delete lots of Linefeeds (Hex \x0a) in a logfile. I just have sed to solve the problem. It is a bit complicated I know.. Do you have idea how to solve the problem? Here is an example ...
2
votes
1answer
36 views

Inspecting how $PATH gets created

Is it possible to "listen" to a variable's value during the start of a new shell? I have a script that checks for the $PATH variable in the typical places, but I'd like to try something different. ...
0
votes
2answers
69 views

redirect command executed along with output shell

I would like to redirect the command executed along with the output to a file. for example: #ls >ls_out.txt ls_out.txt should be something like : ls file1 fil2 Thanks!
1
vote
3answers
679 views

Running ssh-agent from a shell script

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The ...
3
votes
4answers
278 views

Bash one-liner that shows a running countdown until a DNS update (TTL expiration)

I find myself frequently tasked with updating DNS records and needing to know exactly when the refresh will begin (a.k.a TTL expiration). I came up with this bash one-liner that gives me the output I ...
-1
votes
2answers
122 views

Try the command multiple times [closed]

I need to execute a command and also check if it was successful. If there was an error, I should try again and the following code is working as expected. But what if I need to try the same command 3 ...
-1
votes
2answers
960 views

Shell script :: Reading a column from file & store it in array [closed]

I am working on shell script where i want to store O/P of the command in array. I have a file containing rows & columns from where i want to extract 3rd column & store all values in a array. ...
2
votes
1answer
105 views

How do I find the biggest files on multiple servers and sum up their size?

I am trying to find the biggest files in the /export/home directory and add up (sum) their sizes. Script: #!/bin/bash filename=hostnames > export_home.log while read -r -a line do ...
0
votes
1answer
231 views

can't access sourced variables inside Upstart script stanzas

I'm trying to use the variables defined in /etc/environment in an upstart script. I'm able to export the variable to the child process but for some reason I not able to use them in the upstart script ...
-1
votes
1answer
42 views

Different behavior from ubuntu server and ubuntu client on windows [closed]

#!/bin/bash # Reading cat /home/radiare/Desktop/first.txt | while read LINE do if [ "$LINE" == "false" ]; then echo "Inside first loop" break fi done cat /home/radiare/Desktop/second.txt | while ...
1
vote
4answers
72 views

Howto: command/tool ability check

When developing a shell script that should run on various unix/linux derivates, i sometimes have the problem that some tools have to be called in a different way compared to other systems. For example ...
0
votes
1answer
78 views

ZSH escaping / file matching pattern

This works from command line: scp -r ^.git b:/home/wopi/blyzics/. when I paste the above line in a script like this: #!/usr/bin/env zsh scp -r ^.git b:/home/wopi/blyzics/. And run it ...
0
votes
2answers
367 views

How to add a variable into a grep command

I'm running the following grep command var=`grep -n "keyword" /var/www/test/testfile.txt` This work just as expected but I need to insert the file name dynamically from a loop like so: var=`grep ...
2
votes
2answers
1k views

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I ctrl+C the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It ...
1
vote
1answer
113 views

The plugin of munin is always timed out

I want to use munin to make a graph of ttyACM0 in Linux, but munin can not create the graph. I found some information in "munin-node.log". it shows that "Service 'temperature' timed out". So I changed ...
0
votes
2answers
2k views

syntax error near unexpected token `then'

I created bash script wich works as Nagios plugin. Here is a part of it: 44 CURDUPLEX=`ethtool $IFACE|grep "Duplex"|cut -d ':' -f 2|xargs` 45 CURSPEED=`ethtool $IFACE|grep "Speed"|cut -d ':' -f ...
1
vote
4answers
135 views

How to execute shell scrips without creating files

How is it possible to execute a shell script without creating a file? For example assume I have the following script (testscript): #!/bin/bash function run_free() { free -m } run_free I then of ...
2
votes
2answers
659 views

Can I change the ownership of all the files of a specific user?

Is there a way to recursively find all files owned by a user and change them to another user/group in Gnu/Linux? I assume there must be some magic one liner but my command line wizardry skills are ...
1
vote
2answers
467 views

How to untar a single file from an archive with randomly generated directory names?

I'm trying write a script that will download a tarball from github and extract a single file from it. However the top level directory inside the tarball has some random characters in it, which I ...
2
votes
2answers
185 views

Tomcat server getting restarted frequently

We have a script like below to monitor our server. During this code our server getting restarted. Can anyone please explain the meaning of below script? if [ -f $HOME/catalinamonitor ]; then echo ...
0
votes
3answers
81 views

shell script + match MAJOR and CRITICAL strings from log file

I need to match lines that have MAJOR and CRITICAL strings that comes after the word ERROR:< any integer number > please advice how to do that with one awk or sed command? more HW_Log.txt ...
1
vote
1answer
106 views

shell script + add inside the script PATH for standard output

Usually if we want to redirect script output to file we simply do /etc/create_connection.sh > file.debug.txt Or /etc/create_connection.sh | tee –a file.debug.txt But What I want is ...
1
vote
2answers
825 views

Shell script to start mysql server if not already running

I have a shell scipt and at some point I want to check if mysql is running and start it if it's not. I'm trying the following, but not having any luck: set mysqlstatus = `sudo ...
0
votes
2answers
454 views

Shell script to change uid for user

I have a file (users_uid) with users and uid are two parameters as given below : assds 611 dsdsd 612 xyzx 613 rerer 614 These users exist in the machine. I want to change the ...
3
votes
4answers
2k views

From a shell script, how can I check whether a table in MySQL database exists or not?

I am trying to write a script which allows a user to select the what manipulation he needs to do on a table. I want to check if the table exists or not. If it exists I will continue the other things ...
0
votes
2answers
114 views

export command within shell script

When I use export command at command prompt, it works as expected. But it does not work from shell script. [root@server shantanu]# export myip=10 [root@server shantanu]# echo $myip 10 [root@server ...
0
votes
2answers
47 views

Highlight code line by line

Following is the shell script that is expected to pick one line at a time from a given file highlight it. #!/bin/sh > myhighlight.txt file='to_study.php' cat $file | while read -r myline do export ...
2
votes
6answers
111 views

Copying files from a server to a set of machines

First of all I am not a trained professional in Networking nor I know much about it. I have some knowledge of GNU/Linux, Shell scripting. One day I wanted to copy a large zipped file to a set of ...
2
votes
3answers
822 views

Shell script to scan size of directories and email when too big

I am at work right now, and my superiors asked me to write/find a shell script for the Red hat Server edition that checks a folder size, and if it's above a certain limit, it will send an email.Can ...
0
votes
1answer
940 views

creating folder with date range linux shell or C

Hi i need to create a series of folder with a range of date for exmaple createdir 2010-02-02 2010-02-05 will create : 20100202/ 20100203/ 20100204/ 20100205/ What the best way to do this ...
2
votes
3answers
3k views

control a bash script with variables from an external file

I would like to control a bash script like this: #!/bin/sh USER1=_parsefromfile_ HOST1=_parsefromfile_ PW1=_parsefromfile_ USER2=_parsefromfile_ HOST2=_parsefromfile_ PW2=_parsefromfile_ imapsync \ ...
2
votes
2answers
466 views

What is the best Android phone for remote ssh administration/scripting? [closed]

I've got a Moto Droid that I use with connectbot for remote admin on Linux webservers. However, I'm wondering if there are any Android phones out there with better hard keyboards for use with ...
4
votes
2answers
3k views

Unix separate multiple commands which has '&' (execute in background) in the end

To separate regular commands in Unix is to put semicolon in the end like this: cd /path/to/file;./someExecutable; But it seems not working for commands like this: ./myProgram1 > /dev/null & ...
2
votes
4answers
818 views

How to lock user in a shell script program?

Let's say I have a Linux OS without desktop environment. After the PC finish boot up, it will directly show the shell terminal to the user. I plan to write a shell script program and make it ...