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)

1
vote
1answer
77 views

Why are UNIX shells like this and how can I work around it?

One of the things I've noticed about BASH and other UNIX shells is that, by default and when used in typical ways, they spawn subshells for almost everything. e.g. foo=$(grep "someword" ...
0
votes
0answers
17 views

Is there a version of script that plays nicely with vim?

man script says: Certain interactive commands, such as vi(1), create garbage in the type‐ script file. Script works best with commands that do not manipulate the screen, the results ...
0
votes
1answer
55 views

Telnet no echo output from xinetd script

I have have installed xinetd, and I wrote a script: #!/bin/bash echo "Some text" touch /home/somefile I made a service configuration under /etc/xinetd.d/ and basically it works when I connect to ...
0
votes
2answers
45 views

Bash script: test command -o option

I have a piece of code like this: count=0 until [ -f $filename -o $count -ge 60 ] do count=$((count+1)) sleep 1 done I know [ -f $filename -o $count -ge 60 ] is a test command, "-f $filename" ...
3
votes
1answer
30 views

More shell scripts than one in one text file?

I am learning shell scripting for my introductory UNIX course at my university, and I`m curious if is it possible to have more than one shell script in one text file. What I mean by that is, for ...
3
votes
3answers
162 views

Having an issue searching for a string in a file

I have tried to use a 'case' loop but it doesn't work for a reason unknown to me. This is my script for the case loop. echo "Do you wish to search again? [y/n]" read INPUT_STRING2 case ...
0
votes
1answer
57 views

Uuencode displaying attachment content in email body

I am using uuencode with mailx to attach a zip file. In following code, the if block works perfectly and I get Deletions.zip as an attachment in the email. But, whenever the else block is executed I ...
6
votes
2answers
276 views

Compare two files and print matches

Is there anyway to get this through Unix shell scripting? I have a fileA with one column (1000 rows), and fileB with 26 columns(13000 rows). I need to search each value of fileA with fileB and return ...
2
votes
1answer
94 views

Opening a terminal other than xterm, running a command on it, and not closing the terminal after it succesfully finished

I have the following script in my arch linux box: #!/bin/bash xterm -e "sudo pacman -Syu;bash" This will fire up an xterm, and run the command sudo pacman -Syu on it. Because of the ;bash part, it ...
0
votes
1answer
60 views

Got “syntax error near unexpected end of file” in bash script

I'm making an script that gives me a day like this jjj/yyyy when I give it a day like this dd/mm/yyyy and I need it to have an error when you don't write correctly but I'm starting and it's not ...
6
votes
2answers
169 views

how to mount a range of drives in bash?

I use something like this to unmount a range of drives: umount /dev/sd[c-k]2 Is there any way to use same thing with mount? something like this: mount /dev/sd[c-k]2 /[c2-k2]
2
votes
3answers
355 views

How do you fire a sequence of commands at the command tool?

I had a previous question (deleted it) and I still don't understand why it is so hard to understand what I'm trying to ask, but I'll try once again and more clearly. So I'm copying over several ...
3
votes
2answers
69 views

Compare 2 tab delimited files and output differences with column header

I would like to compare 2 similar files on a common column. The files will have identical headers. file1.txt mem_id Date Time Building aa bb cc dd ee ff ...
2
votes
1answer
23 views

Work out the command line of a GUI operation?

I am trying to script one repetitive operation within an open-source software, FSLView to be specific. The operations are extremely straightforward in the GUI, I mean just several clicks. However, I ...
2
votes
1answer
28 views

create numbered files with defined content with bash

I want to create 69 files with a filename from 4006 through to 7075 and it each file needs to have some enumerated content, the following code prints on the shell what I would like to have inserted ...
2
votes
2answers
58 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
1answer
129 views

Pattern replacement

Please can anyone explain to me in brief the syntax of this command. Explanation in terms of how actually this command is written significance of each and every character used. I know the output of ...
3
votes
1answer
33 views

How to save the result of printf to a variable in GDB?

(gdb)printf "Hello %d", 7 Hello 7 (gdb)set $MyVar = printf "Hello %d", 7 // ??? How to save the result of printf "Hello %d", 7 to $MyVar?
3
votes
3answers
145 views

How to mask passwords in 'watch' command?

I am using watch to monitor the progress of a MySQL replication slave. The way I have it set up now, the password shows up in the header of the watch output. I am not exceedingly worried that someone ...
3
votes
1answer
43 views

Read target of symlink and increment target by one

I have a folder structure that looks like this /some/folder/1 /some/folder/2 ... and a symlink current that links to one of the folders. Is it possible and when how to read the target of the link, ...
2
votes
1answer
29 views

Script command without output

Is there something similar to script that records ONLY the commands and not any output from them to a file?
1
vote
0answers
72 views

Startup script with LSB headers not working correctly (dependency problem)?

I am creating a startup script for my Ubuntu 14.04.1 LTS server. The script need to be run after the Rabbit MQ server. The Rabbit MQ startup script says it provides "rabbitmq-server". So I put this ...
-3
votes
2answers
33 views

how to take the file names from folder

i want to write a program for the below logic: Take the names of files in a folder For each file: print file name move the file to another new folder (with the name in dd_mm_yy format)
1
vote
3answers
168 views

How to get a response from any URL?

I have been asked to write a shell script To check if a URL is UP/Working or not for my Project. I tried to find some hints over the internet, but whatever I got is about checking whether the URL ...
2
votes
3answers
255 views

Run a script on multiple shells?

I have two servers one AIX with default shell ksh, the other RHEL with default shell bash. I have a script that is mounted on both that will run similar commands but for either AIX or Linux. This ...
1
vote
1answer
93 views

Compare file size of multiple files in an array [closed]

Scenario: Ftp site has 100s of files. Once a day, all the .gz files are copied to an AWS site then renamed. Only the date is kept in the file name. Some of the files corrupted during copy. A txt ...
1
vote
4answers
73 views

Delete all but largest file in multiple directories

I have multiple subdirectories in /home/usr/ProjZ/programs/ that each contain multiple (or one) .js files. What I need to do is delete all but the largest .js file, if the subdirectory contains ...
3
votes
1answer
161 views

Preserve formatting when command output is sent to a variable? [duplicate]

I have a bash script. If I run this command to: grep for certain patterns, transform the output, sort the output dedupe the output then I get one grep find per line in terminal LC_ALL=C grep ...
3
votes
2answers
104 views

split a file, pass each piece as a param to a script, run each script in parallel

I have a words.txt with 10000 words (one to a line). I have 5,000 documents. I want to see which documents contain which of those words (with a regex pattern around the word). I have a script.sh that ...
0
votes
0answers
46 views

bash script loses readonly value after first time thru loop

I have a bash script which seems to lose the value of the readonly constant after the first time thru the for-in loop. For example: #!/bin/bash readonly DIR="./groups/" for output in "${array[@]}" do ...
1
vote
2answers
92 views

List all the html tags in a file

I want to know if there is a way to list all the html tags in a file. Lets say I have a file file.html <html> <head> <title>Test</title> </head> <body> This is a ...
2
votes
2answers
39 views

I seem to be “losing” this prompt. What is happening?

I ssh into an ubuntu 12.04 cloud server and start a web server like this (w/ bash): $ nohup python tserver.py & [2] 2122 $ nohup: ignoring input and appending output to `nohup.out' After I run ...
1
vote
2answers
243 views

How to iterate through multiple file extension without caring about case sensitivity?

I've seen various topics on how to iterate through multiple file extensions but in most case, the list is defined. example: for file in ${arg}/**/*.{txt,h,py} do .... done As can be seen, ...
5
votes
3answers
316 views

How to iterate through a list of files with spaces that is sorted (case insensitive)?

I am doing this in OSX which uses bash but obviously, not all bash conventions are used so hopefully your suggestion is available to me :) I have the following files fun bar1.txt Foo bar2.tXT ...
2
votes
1answer
88 views

Fetching Remote Windows System Information From Linux Server

I need a script/command that would fetch Windows System Information (Host Name,User Name, Domain, OS Info, Hardware Info, Memory Info, processor Info, etc) by running it on a Linux Server (RHEL 6.5 ...
6
votes
2answers
289 views

Passing arguments from a file to a bash script

I' ve got this situation: ./ ./myscript.sh ./arguments.txt ./test.sh Inside myscript.sh, i have to run the file test.sh, passing to it the arguments contained inside arguments.txt. myscript.sh is: ...
4
votes
3answers
416 views

awk with if statements

I am trying to print from a file using awk, but my output is empty. Here is my code so far accountNum=$1 while read -r LINE || [[ -n $LINE ]] ; do awk -F',' '{ if($1==accountNum) { print ...
2
votes
1answer
73 views

Renaming the files and move to other path

I need to rename the files given below and move to some other path 1234551abcde20140718023216001.txt.809047512.2014_07_07_13:47:44 000001abcde20140718023216001.txt.34568.001.2014_07_07_13:50:44 ...
5
votes
1answer
238 views

Converting .docx files to plain text and preserving line breaks to maintain line number references to source document: howto & implications?

I'm exporting MS Word content to plain text for use with text&file utilities. I have a constraint where the line numbering feature has been enabled in the MS software, and any reference to line ...
0
votes
2answers
261 views

Solution to integer expression expected [closed]

So I when I run this code on my mac there are no errors, and it provides me the perfect output. But when I run it on Ubuntu or CentOS i get the following error integer expression expected ...
3
votes
1answer
114 views

Copy image from clipboard to file

Is it possible to take an image from the clipboard and output it to a file (using X)? I can do this with text easily: $ xclip -selection c -o > file.text But when I try the above with an image ...
0
votes
1answer
57 views

Reusing user input in a script

I have the following script which works: #!/bin/bash xfreerdp /cert-ignore /f /v:farm.company.com /d:company.com /g:rds.company.com /u:$(zenity --entry --title="Username" --text="Username") ...
2
votes
2answers
225 views

Pass argument to script, then redirect script as input to bsub

I am currently working with the bsub job submission system from Platform LSF. I need to submit job scripts, but I am running into a problem with passing arguments to the job script. What I need is as ...
3
votes
1answer
89 views

Run command based on output of another command

OS: AIX 7100-04-1216 So basically I'm trying to write a for loop that sees which volumegroups I have on my system, which filesystems reside in those volume groups and what the size of each of those ...
0
votes
2answers
145 views

If UID=1000 continues, else exit

I am wondering how to implement the following in a bash script. if UID=1000, continue else exit confirm choice (y/n)
3
votes
1answer
132 views

Converting and rescaling a lot of png images to jpeg

I have a lot of .png images in a folder. Is there a command (or software) that can convert all them to .jpg and (simultaneously) rescale the created .jpg files to 25% of their original size?
2
votes
3answers
60 views

How to add a new line for a missing entry between two fields

I have this file. As you can see in column1, entries TEST01N03, TEST01N06, and TEST01N18 are missing (total of 18 entries). Is there a way to check the fields of this column and fill in the missing ...
1
vote
1answer
76 views

Why does the same sed regex (after grep) fail when run in a bash script vs bash command line?

Here's the script. It is successful when I run it from the BASH prompt, but not in the script. Any ideas? When I say "fails," I mean the sed regex doesn't match anything, so there is no replaced ...
0
votes
2answers
77 views

How to count number of instance of a word starting at another word

I need to grep the MySQL-error log starting at today's date formatted like: `date +"%y%m%d"` (140710) And look for all instances of the word partitioned. I've tried various things to no avail. ...
1
vote
1answer
518 views

How to run java service as a non-root user on CentOs 6

I have a script that starts a Java application as a service on CentOS 6: #!/bin/sh # chkconfig: - 80 20 SERVICE_NAME=cn4server PATH_TO_JAR=/usr/local/share/myserver/cn4server.jar ...