02-08-2008
A try with bash
rm old alarm* files
will read an input file called alarms
put any beginning undefined lines into alarm
read thru the file, and based on ! or !! or !!! determine output file
write line to case'd filename
Note: once an alarm file is set, everything will be written there until a new alarm file is calculated.
#! /bin/bash
rm alarm alarm1 alarm2 alarm3
al_fl="alarm"
while read alt
do
al_pr=$(echo $alt | cut -d" " -f1)
case "$al_pr"
in
'!') al_fl="alarm1";;
'!!') al_fl="alarm2";;
'!!!') al_fl="alarm3";;
*) ;;
esac
# echo "$al_pr" "$al_fl"
echo "$alt">>"$al_fl"
done < alarms
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello
I am trying to generate a script to run on worldwide firewalls.
I need the spf block for large sites like google, etc so I can essentially whitelist google sites for users.
(Google here is just an example...)
Right now I am just testing Bash oneliners to see how I can isolate the... (1 Reply)
Discussion started by: mbubb
1 Replies
2. Shell Programming and Scripting
Hello All,
I have a file in the following format. I want to extract the date(020090930, 020090929) in the string "STPAGE020090930" and "STPAGE020090929" and prefix it to all lines below them. The output must be put into a new file.
STPAGE020090930
xyzz aalc... (3 Replies)
Discussion started by: john2022
3 Replies
3. Shell Programming and Scripting
Hello ,
I have file with below content :
'165567885',
'165568443',
'165568805',
I need an awk script that would add a prefix zero after first ' .
Like
'0165567885',
'0165568443',
'0165568805',
Please help.
Thanks in advance. (5 Replies)
Discussion started by: rmv
5 Replies
4. Shell Programming and Scripting
Hi all,
I want to extract some paragraphs out of a file under certain conditions.
- The paragraph must start with 'fmri'
- The paragraph must contain the string 'restarter svc:/system/svc/restarter:default'
My input is like that :
fmri svc:/system/vxpbx:default
state_time Wed... (4 Replies)
Discussion started by: Armoric
4 Replies
5. Shell Programming and Scripting
i'm trying to write a bash script that that will automatically extract zip files after the download.
i writed this script
#!/bin/bash
wget -c https://github.com/RonGokhle/kernel-downloader/zipball/master
CURRENDIR=/home/kernel-downloader
cd $CURRENDIR
rm $CURRENDIR/zipfiles 2>/dev/null
... (2 Replies)
Discussion started by: ron gokhle
2 Replies
6. Shell Programming and Scripting
Dear All,
assume i have a file with content:
<Start>6000</Start>
<Stop>7599</Stop>
the output is:
6000
7000
7100
7200
7300
7400
7599
how should we use any awk, sed, perl can do this task, means to extract the uniq prefixes from the start and stop prefix.
Thanks
Jimmy (3 Replies)
Discussion started by: jimmy_y
3 Replies
7. Shell Programming and Scripting
Hi,
I have a text with a number of paragraphs in them. My problem is I need to locate certain errors/warning and extract/count them. Problem is I do not know how many paras are there with that particular type of error/warning. I had thought that somehow if I could count the number of... (25 Replies)
Discussion started by: dsid
25 Replies
8. Shell Programming and Scripting
In the bash below which does execute I am trying to extract the contents of ${id} is 1234, as ${id} stores the variable that changes each time.
After the path is removed the contents of ${id} are stored in pref, so they can be used in the output. Currently I am not able to extract the 1234 in the... (6 Replies)
Discussion started by: cmccabe
6 Replies
9. Shell Programming and Scripting
In the bash below in each .zip there is a folder to be extracted Variants that I am trying to make unique by adding the prefix, before the _ from the .zip. The script does execute, but the prefix is not added to the extracted folder. Rather the Variants folder is added to each file within it. Thank... (1 Reply)
Discussion started by: cmccabe
1 Replies
10. Shell Programming and Scripting
I am trying to use bash to loop through a directory /path/to/data using a prefix match from /path/to/file. That match is obtained and works using the code below (in green)... what I can not seem to do is populate or update the corresponding prefix_file.txt in /path/to/data with the values in each... (3 Replies)
Discussion started by: cmccabe
3 Replies
alarm(2) System Calls Manual alarm(2)
NAME
alarm - set a process's alarm clock
SYNOPSIS
DESCRIPTION
instructs the alarm clock of the calling process to send the signal to the calling process after the number of real-time seconds specified
by sec have elapsed; see signal(5). Specific implementations might place limitations on the maximum supported alarm time. The constant
defined in specifies the implementation-specific maximum. Whenever sec is greater that this maximum, it is silently rounded down to it.
On all implementations, is guaranteed to be at least 31 days (in seconds).
Alarm requests are not stacked; successive calls reset the alarm clock of the calling process.
If sec is 0, any previously made alarm request is canceled.
Alarms are not inherited by a child process across a but are inherited across an
On systems that support the and system calls, the timer mechanism used by is the same as that used by Thus successive calls to and set and
return the state of a single timer. In addition, sets the timer interval to zero.
RETURN VALUE
returns the amount of time previously remaining in the alarm clock of the calling process.
WARNINGS
In some implementations, error bounds for alarm are -1, +0 seconds (for the posting of the alarm, not the restart of the process). Thus a
delay of 1 second can return immediately. The routine can be used to create a more precise delay.
SEE ALSO
sleep(1), exec(2), getitimer(2), pause(2), signal(5), sleep(3C).
STANDARDS CONFORMANCE
alarm(2)