A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
1
vote
2answers
47 views
How to sum times in a text file using command-line?
I have a text file containing flight times, hours and minutes separated by colon sign, one per line:
00:50
00:41
00:43
00:50
01:24
I am currently using Apple's Numbers application with a simple ...
0
votes
2answers
19 views
merge mutiple files using common column [duplicate]
Say I have multiple files x1, x2,x3,x4, all with common header date, time, year, age.
How can I merge them to one singe file X in shell scripting?
File x1:
date time year age
101014 1344 2012 52
...
2
votes
2answers
29 views
Interacting with a running interactive console program from a different process
I have a console program with an interactive shell, similar to say, the Python interactive shell. Is there an easy way to start this interactive program A and then use another program B to run A? I ...
2
votes
1answer
29 views
Get the full window dimensions (including decorations) in Unity
I have used the answer to How do I find the window dimensions and position accurately including decorations? in my bash scripts, and had good success with my Silentcast application on Xfce, but now ...
0
votes
0answers
21 views
Can't set PATH with a script [duplicate]
I have written a script which was supposed to add some value to environmental variable PATH, but script doesn't do that if I start it with ./script.sh.
#! /bin/bash
INSTALLDIR="/opt/ARM"
...
5
votes
1answer
168 views
How do I print all but the Nth to last line in sed?
I'd like to do the complement / "opposite" of
sed 13q;d <file.txt
More generally, is it possible to do this sort of
complement/inverse/opposite in sed? Or only for regexes?
How do I print all ...
1
vote
0answers
18 views
Maintain screen session when executing shell script on boot
On Ubuntu 14.04, I have a crontab entry set to run on reboot:
@reboot /root/start_server.sh
And here's start_server.sh:
screen -dmS server bash -c "cd server ; ./run.sh"
When the system starts ...
1
vote
3answers
39 views
Find a string in one section of a file with mutiple sections
How to sed/awk for a string contained in another string.
TESTVAR='
{
icon : "icons/773_l.png",
id : 80,
initialState : true,
isPng : false,
label : "Imagery",
opacity : 1,
requestType : ...
1
vote
1answer
46 views
Is it possible to create a Linux environment without a traditional command shell?
i.e.
Using something like IPython, re.pl, or somesuch as a login shell, instead of bash/ksh/etc.
Using initscripts, etc. written in Python or some other scripting language, and making no use of ...
0
votes
2answers
12 views
7z from bash script won't exclude directories
I've encountered with kinda strange behaviour of 7z (or bash, I don't know yet.).
With the following script:
#!/bin/bash
find /home/user -type f -name "*.pdf" | cut -c 10- > ...
1
vote
1answer
16 views
how do you include variables in Bind9 configuration files?
I am trying to create a auto install script since I have to do this installation task on multiple servers.
I have setup all the bind9 configuration files with my variables and thought it would have ...
1
vote
2answers
51 views
Concatenate file contents AND names
I've been writing for many months. The files I create are dated files named like 2011-06-13.markdown with daily content. I've decided I want to have all the writing in one file instead but I'd like ...
1
vote
1answer
74 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
13 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
19 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
39 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
25 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
156 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
39 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
262 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 ...
-3
votes
0answers
28 views
How to extract strings from a given input file and store them in two different files in a column wise manner
Given below is the input file pattern:
***********************************************************
Search URL: ...
2
votes
1answer
56 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
46 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
152 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
325 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
55 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 ...
-3
votes
0answers
16 views
I am having trouble with a problem my buddy game me [migrated]
SCRIPTING PROBLEM: Command Output Parser
Write a script/program to parse the output of the command 'cat test_file.txt' (see linked file)
The program should:
Create a new file for every server. The ...
2
votes
1answer
19 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
24 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
51 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
122 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
30 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
131 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 ...
2
votes
1answer
38 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
27 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
39 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
29 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
106 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
150 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
63 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
63 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
132 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
85 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
41 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
77 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
36 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
212 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
228 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
68 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
128 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:
...