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

learn more… | top users | synonyms (2)

3
votes
2answers
34 views

How can I propagate my SSH pub key to a list of servers without having to type my password in over and over?

I was recently given username/password access to a list of servers and want to propagate my SSH public key to these servers, so that I can login more easily. So that it's clear: There is not any ...
1
vote
2answers
23 views

Url Decoding shell script

How can I store the url-decoded string in a variable using shell script #!/bin/sh alias urldecode='python -c "import sys, urllib as ul;print ul.unquote_plus(sys.argv[1])"' ...
0
votes
1answer
15 views

Help killing off Process for Mem Leak

I am currently building an Android LP kernel, and have some pretty sweet tweaks already running and built into it. I know there are numerous LP memory leaks (i've already got the bootanimation one ...
-1
votes
1answer
25 views

Webpage content - search for pattern & save to file

I have a web page, say https://test.salesforce.com. I would like to search for a pattern, e.g. "src" at the beginning of a line in the entire webpage content. If the pattern is found, I need to ...
0
votes
0answers
22 views

Run Loop between starttime and endtime and get data from url

I want to check two conduction and run a loop for every one minute. There should be three variable start_time, end_time and current_time Conduction's: start_time should be greater than ...
2
votes
1answer
41 views

How do I properly escape this long su + sed command?

#!/bin/bash wineuser=tom su $wineuser -c "sed -i '$ialias ptgui "wine ~/.wine/drive_c/Program\ Files/PTGui/PTGui.exe\"' /usr/people/$wineuser/config/cshrc.csh" The acutal line inserted to tom's ...
13
votes
3answers
298 views

Prepare answers for questions of a command

Let's say I want to write a shell script that executes just one command. But this command is poorly designed. It doesn't offer any command line options; instead it asks some questions and waits for ...
1
vote
0answers
36 views

Shell Script to change user shell

I am writing a script that would be invoked to change user shell. The basic requirement is that once user gets authenticated (e.g: thorough some web application) the script would be invoked to set the ...
1
vote
1answer
46 views

Getting an output error with command head in shell script

getting an error with head command. There are two files with size 48bytes in directory and its printing once along with the directory path instead of twice. Why the head command is not considering the ...
1
vote
0answers
24 views

Inherit IO redirections from a script to another

When I redirect the output of a script within a script, I expect the redirection to be applied to the called script as well as the program called within it. A: ./B 2>> error.log B: ...
0
votes
1answer
26 views

Delete excel files which are older then 1 month

I need to delete excel files which are older then 1 month. need to set cronjob. any suggestion for this? which script can be used to search excel files from particular directory and delete them.
0
votes
1answer
34 views

need to get the command information over ssh and the input from file

I am writing a script to get the command information of the remote machine usinf while and for loop. PFB the script. But the script ends by giving the single command information only. I have multiple ...
1
vote
3answers
73 views

How to decode base64 text in xml file in Linux?

I'm new in linux (shell). I need to decode base64 text in xml file using linux shell script. Could you please help me to write linux shell script for decoding the values of those tags where attribute ...
0
votes
1answer
22 views

Percent Signs for Shell Vars to Remove Extension [duplicate]

for file in *.pdf ; do newname=${file%\\.\*} done I don't understand how the %\.* is removing the file extension, can someone walk me through it.
1
vote
1answer
22 views

Issue Using Crontab to Create/Restart Screen and Run Command

I want to have a certain script (rails rake task) running on my server at all times - it basically populates my DB using a live feed. I can create a screen (http://linux.die.net/man/1/screen) and run ...
0
votes
1answer
36 views

Parsing string on multiple parts without separator

115:wc -l:find . -iname "*test*":find /tmp/ -iname "*test*" I would like to parse the string above. In my case, a string consists of 4 columns (every command has : separator) but it can be much ...
2
votes
3answers
65 views

Help with String manipulation in shell

I was writing a shell script to generate a string in a particular format so that it can be used as a input in one of the XML I am working with. Given a input file in the format <attribute ...
4
votes
4answers
204 views

How can I copy a file in a bash script and rename it while copying and place it in the same directory

How would I copy a file "file.doc" and rename it while copying to "file_copy.doc" and place it in the same directory ? And this only by calling the script and adding the file name in the argument: ...
0
votes
3answers
61 views

How to store the output and print it back again with breaking output into new lines

I want to store the output in a variable and want to be displayed as follows. My code: #!/bin/bash dir=$1 printf "file size: %s\n" \ du "$dir" -hab | sort -n -r |tail -n 2 I want ...
3
votes
2answers
67 views

shell scripting remote commands through ssh

I'm trying to create a shell script which will execute some commands which I require frequently. I made the ssh login to skip the password prompt using a public/private key pair. and after some ...
0
votes
0answers
21 views

Script to restart failed jobs [on hold]

I want to create a script which may have multiple JOB names which will first check the status of a job whether the JOB is failed or successful. If it fails then start the job again. I am a self ...
0
votes
4answers
63 views

Hexadecimal number sequence checker in Linux?

I have a list of hexadecimal number. I would like to check whether they are in sequence or not. That is, they should be consecutive numbers, in increasing order. In other words, there should be an ...
0
votes
0answers
44 views

Shell script to send alert if mount point exceeds 75% [duplicate]

How to write shell script to send an alert if any file-system on server exceeds 75%, in one email notification instead of receiving separate alert email notification for each file-system. I am ...
1
vote
1answer
50 views

what is meant by “^$1” in shell script?

#!/bin/sh #emp3.sh: using if and else # if grep "^$1" /etc/passwd 2>dev/null then echo "pattern found - job over" else echo "pattern not found" fi in the above programme what is "^$1" and ...
1
vote
3answers
130 views

Find records present in file 1 also in both file 2 and file 3

I have three files file1.txt, file2.txt, file3.txt and they are of same format. I want to select records from file1.txt which are present in both file2.txt and file3.txt based on column 2 and column ...
2
votes
2answers
41 views

bash + how to define array variable with instance number

Is it possible to define variable that is called for example machine1 as machine$counter ( while counter=1 ) ? For example, I created the /tmp/config.txt file and set the machine1 as array: $ more ...
-1
votes
0answers
28 views

Is there any command to find a small size automatically? [on hold]

how to find a small file size automatically ? for example: there are 20 files in a directory. 5 files are of same size. The 5 files should be display as output.
0
votes
3answers
30 views

How to match and replace an attribute value inside a tag

I am trying to replace the value of following node using sed command. <KeyValue key="EMPTY_SEARCH_CRITERIA" type="String" value="CS_CODE" comment="Configured empty search criteria."/> I am ...
1
vote
0answers
35 views

Create tree of processes

I'm implementing pstree as an assignment, and I would like to create test tree of processes, but I'm struggling to do so. I tried to do something like this to create tree of background processes ...
1
vote
1answer
30 views

read reading input devided by spaces

How can I read in POSIX bash input like this: <name>,<tag1> <tag2> <tag3>… I tried while read line;do done but this wants newlines, all I have is spaces. (Is IFS solution? ...
-2
votes
0answers
29 views

Find HTML tag and add it to text editor with script [on hold]

Is there a way to open a website find a specific HTML tag and get inner text (or inner HTML) and paste it to text editor or text file. I'm new to Linux.
1
vote
1answer
44 views

Searching a filename

How to search a file with a given String and currentTimestamp and if not found trigger a mail? For Ex-:I have to search a file whose filename would be like filename_05172015 and trigger a mail if not ...
0
votes
0answers
30 views

Shell Scripting - return to previous loop until process is completed then die/done

I am writing a bash/shell script to automate some file filtering functions. I am stuck due to being new to scripting and I am not sure how to code the function in it to keep looping the top section of ...
-2
votes
0answers
45 views

Convert perl to shell/bash [closed]

I understand C and C++ and new to perl scripting. I must convert the perl script under the following url to shell or bash: busware Here is the code: #!/usr/bin/perl use warnings; use strict; use ...
1
vote
1answer
26 views

Assigning ls output to a variable gives unexpected behavior

I was writing a script to clean a text file from a directory (I know,it's a bad idea but I really need it) and I wrote this: #!/bin/bash var=$(ls -p /direcotry/to/file | grep -v /) truncate -s 0 $var ...
3
votes
2answers
78 views

Create a file of pairs from pairs

Say I have the following file: A 1 B 2 CC 33 And I want to create a file containing every combination of two from the previous file, like this: AA 11 AB 12 ACC 133 BA 21 BB 22 BCC 233 CCA 331 CCB ...
1
vote
2answers
66 views

Is there any way to send sms to a mobile number using shell script?

I want to send sms periodically to certain Mobile numbers (Indian mobile numbers.) Is there way I can send with my own cellphone number or by creating account in sites like way2sms , etc. Thanks in ...
0
votes
1answer
46 views

Cannot get interface information using read

The following link has a script to get system information: z3bra' blog Specifically, network() { read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` if iwconfig ...
-2
votes
1answer
53 views

How to properly use awk in ksh?

I have: 1 #!/bin/ksh 2 BEGIN { print "START" } 3 { print "Hello World" } 4 END { print "STOP" } 5 6 7 exit 0 then when I try to run the file the following errors appears: ...
1
vote
2answers
75 views

Script to read line by line from a file pipe that to another command and output to another file

I've got this weird old app that I'm trying to support and it stores the passwords in plain text and I'd like to hash them. I'd really like to have an input file in csv with a username,password for ...
2
votes
2answers
47 views

How can I start a file-processing daemon? [closed]

How can I run a script-based tool which will process files continuously downloaded to given directory as they arrive? I'd like to minimize delay (~1 second is OK), script can have own infinite loop. ...
0
votes
1answer
53 views

Creating charts from the data extracted from csv file and mail the chart as content in the mail body [closed]

I running mysql queries and put the data in csv file and mailing the same using shell script.[This is an automated script] I want to create a chart out of the csv data and put it in the mail body and ...
-2
votes
2answers
35 views

Shell script in unix for process monitoring of web server and write it into file [closed]

How can I monitor current process running on my web server and write them with it's all detail into one file for every second using shell script?
1
vote
1answer
16 views

Create SOX batch script to extract first 15 seconds and rename multiple files in folder

I have a folder with several MP3 files that I need to extract 10-15 seconds of audio from. I would also like to rename these by appending sample-(name).mp3 to the converted files. How can I do this ...
1
vote
1answer
56 views

Run ./script.sh vs bash script.sh - permission denied

When I try to run ./script.sh I got Permission denied but when I run bash script.sh everything is fine. What did I do wrong?
0
votes
2answers
49 views

Create user from bash script

I'm in the process of making a bash script to automate adding a user. My password always have pattern, so I am setting that to a variable then... (this is where I am stuck -encrypting-). I found this ...
1
vote
0answers
34 views

What's in your script Swiss Army knife? [closed]

I've been using Linux pretty heavily that past few months and I want to up my game. But so far my scripts have been focused on speeding up my development time. I'm looking for scripts that will just ...
3
votes
2answers
45 views

Can I change how select options are displayed?

I'm working with select and case in bash. I currently have nine options, which makes a nice, tidy, 3x3 grid of options, but it displays like so: 1) show all elements 4) write to file 7) ...
0
votes
1answer
13 views

makeing a script to change Java SDK

I actually have the script running, but I think it's not very efficient and the only way to get it to take is to run it as "source change-java.sh" Is there a way to get it to not have to output to a ...
3
votes
2answers
67 views

How to use a bash function like a regular command in a pipe chain?

I'm performing several commands on large files from within a bash script. In order to monitor the progress I use the pv command. An example command could look like this cat $IN_FILE | pv -w 20 -s ...