Tagged Questions
5
votes
3answers
140 views
Walking through files in directory randomly
How to change for track in *.mp3; do so that all .mp3 files in the current directory are walked through but in a random way?
0
votes
2answers
76 views
How to create as many variables as needed from shell script(bash)?
I'm making a script for monitoring some user processes with Upstart but, since its for the company I work for, they asked me to do it generic...how's so?
Well, the number of processes being monitored ...
1
vote
3answers
43 views
Solaris: Script for finding the physical device path of all installed fiber cards
I have a number of systems (with quite varying type, generation and architecture unfortunately).
I need to create a list of fiber cards on these varying systems.
I am able to use prtconf -v, and ...
0
votes
2answers
57 views
Executing a program according to the last modified date
I need to write a script which would execute some executables in a directory according to the last modified date. The oldest should run first. How do I do it?
This is what I have done so far
for f ...
2
votes
2answers
77 views
What scripting language can I use to automate a concatenation & zipping process?
For a project I'm doing I need to concatenate and compress (with zip) many (midi) files and compare their sizes. I've thought there must be some language that allows me to do something like this:
...
0
votes
1answer
52 views
How to get the arguments to a php function via grep?
I am writing a script to let me know the database login info for each PHP-based web site on a server that I am migrating. The login information is usually done either like this:
...
2
votes
1answer
41 views
Bash: pair up two series of files
I have a number of files with this pattern:
file1_foo.ext
file1_bar.ext
file2_foo.ext
file2_bar.ext
and so on.
I need to "pair them" and put them in a file like this
file1_foo.txt ...
3
votes
1answer
97 views
Searching for Failed attemps in /var/log/secure
I'm currently writing a script to examine /var/log/secure file and report how many failed attempts there were that day. I need to output it in the following format:
Date: 03/15/10 Time: 10:30 Number ...
2
votes
1answer
251 views
Create sub-directories and organize files by date
I have some directories of files copied from my security camera that I would like to organize into sub-directories by file date. So for example;
-rwxrwxrwx 0 root root 4935241 Jul 19 2012 ...
1
vote
1answer
76 views
Running a script as Grub boot option
I'm assembling some DR stuff for my Linux boxes. One item that would be really handy would be a GRUB option that would run a script to change my boxes from static IPs to dynamic.
I know we could do ...
2
votes
1answer
111 views
bash scripting add arguments
I have created a script which takes parameters and arguments. I want to insert the --help argument.
I already know how to parse normal arguments with -, but I don't know how to parse the -- ones.
to ...
3
votes
2answers
328 views
Iterate over multiple parameters with spaces in bash script
I have a bash script for my RaspberryPi (running Raspbian) that is supposed to take multiple file names as parameter(s) and play one after the other (using omxplayer). The basic structure is this:
...
0
votes
1answer
85 views
How do I write a script to keep retrying Yum Update Program?
My job let me always release a new version of the program to a satellite server, then in the running server, I use yum update program to update the program.
However, due to unknown reason, in most of ...
2
votes
1answer
60 views
How to set Cols and Lines for a Subprocess
I have a script that runs a series of scripts numbered 001,002,003,004... etc down to 041 right now, will be more in the future - and these scripts them selves use some cursor control to print a ...
0
votes
1answer
73 views
why there is random behaviuor for a background job?
going through advanced bash scripting guide example 3.3 running a loop in background, i found this :
#!/bin/bash
# background-loop.sh
for i in 1 2 3 4 5 6 7 8 9 10 # First loop.
do
echo -n "$i "
done ...
1
vote
2answers
245 views
Concatenate multiple files under subdirectories
My directory structure is given below
x:\Project_2012-158A\Sample_4041
SampleSheet.csv
4041_CGTACG_L002_R1_001.fastq
4041_CGTACG_L002_R2_001.fastq
4041_CGTACG_L006_R2_001.fastq
...
2
votes
1answer
141 views
How to capture text formatting in bash?
The following shell script works but removes colored formatting generated by rspec:
#!/bin/bash
OUTPUT=`rspec`
echo "$OUTPUT"
How to preserve the colors?
2
votes
2answers
306 views
Parse apache logs to exclude IP ranges
I need to look for some requests in a huge pile of apache logs. My only requirement is this:
I need to only view the requests coming from any IP address that is NOT included in a list of 50 IP ranges ...
0
votes
1answer
139 views
How to effectively use bash scripting (different cost reductive ways and good habits)? [closed]
This is one of the most perennially important questions. How to effectively script ? What are the bad ways and what are the good ways ? I know of some, which i will point out here. If anybody does ...
1
vote
1answer
339 views
How to manage getops argument assignation
This is my first question.
I'm trying to make a small script with options and I'm using getopts to do it. The weird thing is:
The argument don't get assigned to the variable or it always enter the ...
0
votes
1answer
363 views
Shell script to recursively grep data from certain files in the directory and return values to file [closed]
I am making a simple shell script which will minimize the time I spend in searching all directories under a parent directory and grep some things inside some files. Here's my script.
#!/bin/sh
...
4
votes
2answers
131 views
Dealing with script interruption
I need to iterate over between 120k and 500k files. find handles this well.
find $PWD -type f -path "fragments/*.pdbqt"
For some reason I want to list the same set of files again, in the same ...
11
votes
3answers
947 views
What does it mean to have a $“dollarsign-prefixed string” in a script?
I just saw this in an init script:
echo $"Stopping Apache"
What is that dollar-sign for?
My research so far:
I found this in the bash manual:
extquote
If set, $'string' and ...
1
vote
1answer
270 views
Parsing SQLite output
Using -line Option I get this output from SQLite:
row1_column1 = valueA
row1_column2 = valueB
row2_column1 = valueC
row2_column2 = valueD
So one line for each column value and result rows are ...
1
vote
2answers
287 views
What scripting language or platform to use for web page downloads and screen interaction? [duplicate]
Possible Duplicate:
Does anybody here have experience in automating some tasks in web applications using curl?
Here is what I need to do? Wondering what platform is most suited - easy to ...
3
votes
4answers
462 views
How do you colorize only some keywords for a bash script?
I am running some unit test code. The unit test code outputs regular text. There is a lot of the text so I want to highlight for the user important keywords.
In this case the keywords are "PASS" and ...
5
votes
4answers
3k views
How can I use bash's if test and find commands together?
I have a directory with crash logs, and I'd like to use a conditional statement in a bash script based on a find command.
The log files are stored in this format:
/var/log/crashes/app-2012-08-28.log
...
3
votes
1answer
184 views
Locking in a shell script
I want to write a long-running shell script so that only one copy could be run at a time. If the script crashes, I want a new invocation of the script not to be stopped by a lock from the crashed ...
4
votes
1answer
73 views
Transform directory structure
I have the following folder structure
root folder
|-al2
|- GER.zip
|- ENG.zip
|-ww
|- GER.zip
|- ENG.zip
and so on. The folder names are random strings.
I want to sort the files in ...
0
votes
1answer
138 views
How does “options” in shell scripting work?
I found some code in one of the answers here and accommodated it to my needs but now I have two questions:
Q1: how can I display the options text after the code in case statement finishes? So the ...
2
votes
3answers
394 views
Copy/backup all dirs containing files matching a regexp
I would like to do a backup where I recursively go through a dir structure and only get directories with files whose names matching a particular regexp. I would like to keep the directory structure, ...
3
votes
2answers
903 views
assign shortcut key to run a script
I've written a script to change the brightness of my screen.
It's useful when I am working on text mode and shortcut keys of my keyboard to change brightness doesn't work.
Is it possible to run this ...
3
votes
3answers
1k views
Shell Script to Execute Shell Script to All Subdirectories
I am making a script to simplify my daily tasks. Everyday, I have to grep for a few things inside a company server. It was okay, however, now, they have segregated each object into sub directories. I ...
6
votes
4answers
2k views
printing colored text using echo
I know that for printing a colored text using echo, for example red color, the code is: echo -e "\e[1;31m This is red text \e[0m"
and I know that in this example, 31 is code of red color and the ...
3
votes
2answers
374 views
is there any command like “wall” that runs a “command” in all terminals
as you know "wall" command sends a message to all terminals:
wall message
now my question is this: is there any command that can send a "command" to be run in all terminals?
for example sending ...
5
votes
2answers
562 views
How to tweet using terminal?
I would like to tweet a message using terminal.
I tried something like:
curl -u 'TwitterUsername':'TwitterPassword' -d status=”Your Message Here” https://twitter.com/statuses/update.xml
but seems ...
0
votes
2answers
253 views
Re-assigning (specifically, incrementing) a variable in a bash script [duplicate]
Possible Duplicate:
How can I do command line integer & float calculations, in bash, or any language available?
I would like to simply re-assign a variable (to be specific, increment it ...
1
vote
2answers
1k views
How can I trim the carriage return from text that is being piped in bash?
I'm using this command to get my last typed command:
history | cut -c 8- | tail -n 2 | head -n 1
It works very well in bash, removing the line numbers, but there is one problem I have with it, (er, ...
6
votes
4answers
2k views
Parallel execution of a program on multiple files
I have a small script that loops through all files of a folder and executes a (usually long lasting) command. Basically it's
for file in ./folder/*;
do
./bin/myProgram $file > ./done/$file
...
1
vote
2answers
128 views
how to detect command interpreter from within a shell script [duplicate]
Possible Duplicate:
How to test what shell I am using in a terminal?
For example the following script
#!/bin/bash
issue_interpreter_name
would issue:
bash
9
votes
6answers
603 views
Text Manipulation Across multiple lines
I Have a file that has text like this:
AAAA
BBBB
CCCC
DDDD
1234
5678
9012
3456
EEEE
7890
etc...
And i want to match up the Alphabetic lines with the Numeric lines so they are like this:
...
0
votes
2answers
144 views
How to generate Zipf-like samples, by using scripting language
Is there any scripting language function (like in python or bash) that samples from a zipf-like distribution, for exponent 0<a<=1.
PS: I am aware of existence of a numpy function that can ...
2
votes
3answers
274 views
dynamic display of a running process?
I am writing a script and acording to that when i run it certain info will be displayed on the output screen.
for example say the constant data displayed is:
my name is mukesh.
i am 27 years old
...
0
votes
2answers
173 views
Autentification on SSH connection in OneLine [duplicate]
Possible Duplicate:
Shell Script for logging into a ssh server
I need to connect via SSH to a remote server, however I must do this with out interactive mode and with out use Public keys ...
3
votes
1answer
324 views
merging files and getting column values based on id field
bash-3.2$ cat sample.log sample.log.1 sample.log.2
ID COL1 COL2 COL4
1 col1 col2 col4
2 c1 c2 c4
3 co1 co2 co4
ID COL3 COL1
1 col3 col1
2 c3 c1
3 co3 co1
ID COL1 COL2 COL3
1 col1 ...
2
votes
2answers
429 views
Invert results for “for in * do”-loops [duplicate]
Possible Duplicate:
How do I reverse a for loop?
Is there an easy way to invert a for in loop? For a script I want to process files in their reverse order.
So instead of:
for file in ...
0
votes
3answers
138 views
help with script; if status is this do that if not do something else
I need to write a script that checks on the status of something. If the status "Copying" then exit (or retry in 60 minutes if we want to get fancy.) If all there is nothing returned (based on my ...
3
votes
3answers
265 views
How to make svn look for if there is an update once a minute and if there is call some script?
I am developing a server app. I have a remote machine with Debian that I use for testing. Currently I update the server manually when each new svn version comes out. It is just a testing server and ...
2
votes
3answers
653 views
Keep running a script via ssh
ssh can use to run remote commands.
ssh me@server.com 'long-script.sh'
I run a long script that will take a lot of time, but I want to close my computer and keep running the script in the remote ...
1
vote
1answer
333 views
Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again
I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
