04-06-2010
Quote:
Originally Posted by
grepFruit
Hi,
sorry, but you must use the command a (append).
Greeting
Welcome to the forums, grepfruit (love the nick
).
If you look at the sample data provided, you'll see that the inserted text precedes each line. That is not an append.
Regards,
Alister
Last edited by alister; 04-06-2010 at 01:44 PM..
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi,
am a new learner to shell programming.
i have a script which will prompt for user to key in their name & display their name afterwards.
script
=====
echo "Pls enter your name:"
read name
echo "Your name is $name."
output
=====
Pls enter your name:
Bob
Your name is Bob.
what... (2 Replies)
Discussion started by: newbie168
2 Replies
2. Shell Programming and Scripting
Hi All,
I need to print the lines after 2nd line irrespective of the number of lines in file
if the file contents are like below
----------
root:!:0:0::/root:/usr/bin/ksh
daemon:!:1:1::/etc:
bin:!:2:2::/bin:
sys:!:3:3::/usr/sys:
adm:!:4:4::/var/adm:
uucp:!:5:5::/usr/lib/uucp:... (6 Replies)
Discussion started by: ram1729
6 Replies
3. UNIX for Dummies Questions & Answers
I have a file that contains hundreds of lines such as:
this_is_macro,000001
this_is_macro,000002
this_is_macro,000003
I would like to add the variable words
MACROBEGIN MACRO_000001
MACROBEGIN MACRO_000002
MACROBEGIN MACRO_000003
above each line
and add the word
MACROEND
... (2 Replies)
Discussion started by: kenneth.mcbride
2 Replies
4. Shell Programming and Scripting
2 files, first one has 3 fields seperated by ||| and 2nd one is plain text.
I want to copy the lines from the first file if the 2nd field is present anywhere in the text file. This is what I've tried, but I'm new to awk and shell scripting in general so it's kinda broken.
#!/bin/awk -f
BEGIN... (15 Replies)
Discussion started by: FrancoisCN
15 Replies
5. UNIX for Dummies Questions & Answers
Hiii
I wanna a read a line of text from standard input. The user enter data like this way
name phone_no month1_salary month2_salary
that is user enter the name ,phone no and salary of 2 months in a single line by giving spaces. I wanna add the 3rd and 4th fields ...ie add both... (4 Replies)
Discussion started by: krishnampkkm
4 Replies
6. Shell Programming and Scripting
Hi,
I've got a text file with hundreds of lines I need to upload to an API via curl, one by one.
The text file is like:
2012-08-01 10:45,124
2012-08-02 10:45,132
2012-08-03 10:45,114
I want to get curl to go through the text file sending a post for each line.
like:
curl --request... (0 Replies)
Discussion started by: emdeex
0 Replies
7. Shell Programming and Scripting
How can I delete the first '2' characters in the 2nd line and every fourth line thereafter (Means line no.s 2, 6, 10...so on).
For example if the following is my Input
treieieiei
trrpepepepep
tyeueueue
tyeueueeu
tyeyeyeye
tryryry
tyeyey
tyrtyty
tytyty
tututu
tututututu
Output... (8 Replies)
Discussion started by: cs_novice
8 Replies
8. Shell Programming and Scripting
Hi all,
I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like:
<date1>|<data1>|<url1>|<result1>
<date2>|<data2>|<url2>|<result2>
<date3>|<data3>|<url3>|<result3>
<date4>|<data4>|<url4>|<result4>
What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies
9. UNIX for Dummies Questions & Answers
I need to search a string for some specific text which is no big deal using grep. My problem is when the search fails to find the text. I need to add text like "na" when my search does not match.
I have tried this command but it does not work when I put the command in a loop in a bash script:
... (12 Replies)
Discussion started by: jojojmac5
12 Replies
10. Shell Programming and Scripting
Hi dears
i use bash shell
i have INPUT.txt
like this
number of columns different in one
some row have 12 , some 11 columns
see last column
INPUT.txt
CodeGender Age Grade Dialect Session Sentence Start End Length Phonemic Phonetic
63 M 27 BS/BA TEHRANI 3 4 298320 310050... (2 Replies)
Discussion started by: alii
2 Replies
LEARN ABOUT DEBIAN
poe::component::irc::cookbook::seen
POE::Component::IRC::Cookbook::Seen(3pm) User Contributed Perl Documentation POE::Component::IRC::Cookbook::Seen(3pm)
NAME
POE::Component::IRC::Cookbook::Seen - Implement the 'seen' command
SYNOPSIS
This little bot tracks the whereabouts of users and allows you to retrieve that information on command.
19:59:51 * seen_bot (n=hinrik@pool-71-164-43-32.chrlwv.east.verizon.net) has joined #test_channel1
19:59:55 <foo> bar
20:00:16 * seen_bot has quit (Remote closed the connection)
20:00:27 * seen_bot (n=hinrik@pool-71-164-43-32.chrlwv.east.verizon.net) has joined #test_channel1
20:00:29 <literal> seen_bot: seen seen_bot
20:00:29 <seen_bot> literal: I last saw seen_bot at Mon Sep 22 20:00:27 2008 joining #test_channel1
20:00:34 <literal> seen_bot: seen foo
20:00:40 <seen_bot> literal: I last saw foo at Mon Sep 22 19:59:56 2008 on #test_channel1 saying: bar
20:00:45 <literal> seen_bot: seen baz
20:00:48 <seen_bot> literal: I haven't seen baz
DESCRIPTION
#!/usr/bin/env perl
use strict;
use warnings;
use IRC::Utils qw(parse_user lc_irc);
use POE;
use POE::Component::IRC::State;
use POE::Component::IRC::Plugin::AutoJoin;
use POE::Component::IRC::Plugin::BotCommand;
use Storable;
use constant {
USER_DATE => 0,
USER_MSG => 1,
DATA_FILE => 'seen',
SAVE_INTERVAL => 20 * 60, # save state every 20 mins
};
my $seen = { };
$seen = retrieve(DATA_FILE) if -s DATA_FILE;
POE::Session->create(
package_states => [
main => [ qw(
_start
irc_botcmd_seen
irc_ctcp_action
irc_join
irc_part
irc_public
irc_quit
save
)]
],
);
$poe_kernel->run();
sub _start {
my ($kernel, $heap) = @_[KERNEL, HEAP];
my $irc = POE::Component::IRC::State->spawn(
Nick => 'seen_bot',
Server => 'irc.freenode.net',
);
$heap->{irc} = $irc;
$irc->plugin_add('AutoJoin', POE::Component::IRC::Plugin::AutoJoin->new(
Channels => [ '#test_channel1', '#test_channel2' ]
));
$irc->plugin_add('BotCommand', POE::Component::IRC::Plugin::BotCommand->new(
Commands => {
seen => 'Usage: seen <nick>'
}
));
$irc->yield(register => qw(ctcp_action join part public quit botcmd_seen));
$irc->yield('connect');
$kernel->delay_set('save', SAVE_INTERVAL);
return;
}
sub save {
my $kernel = $_[KERNEL];
warn "storing
";
store($seen, DATA_FILE) or die "Can't save state";
$kernel->delay_set('save', SAVE_INTERVAL);
}
sub irc_ctcp_action {
my $nick = parse_user($_[ARG0]);
my $chan = $_[ARG1]->[0];
my $text = $_[ARG2];
add_nick($nick, "on $chan doing: * $nick $text");
}
sub irc_join {
my $nick = parse_user($_[ARG0]);
my $chan = $_[ARG1];
add_nick($nick, "joining $chan");
}
sub irc_part {
my $nick = parse_user($_[ARG0]);
my $chan = $_[ARG1];
my $text = $_[ARG2];
my $msg = 'parting $chan';
$msg .= " with message '$text'" if defined $text;
add_nick($nick, $msg);
}
sub irc_public {
my $nick = parse_user($_[ARG0]);
my $chan = $_[ARG1]->[0];
my $text = $_[ARG2];
add_nick($nick, "on $chan saying: $text");
}
sub irc_quit {
my $nick = parse_user($_[ARG0]);
my $text = $_[ARG1];
my $msg = 'quitting';
$msg .= " with message '$text'" if defined $text;
add_nick($nick, $msg);
}
sub add_nick {
my ($nick, $msg) = @_;
$seen->{lc_irc($nick)} = [time, $msg];
}
sub irc_botcmd_seen {
my ($heap, $nick, $channel, $target) = @_[HEAP, ARG0..$#_];
$nick = parse_user($nick);
my $irc = $heap->{irc};
if ($seen->{lc_irc($target)}) {
my $date = localtime $seen->{lc_irc($target)}->[USER_DATE];
my $msg = $seen->{lc_irc($target)}->[USER_MSG];
$irc->yield(privmsg => $channel, "$nick: I last saw $target at $date $msg");
}
else {
$irc->yield(privmsg => $channel, "$nick: I haven't seen $target");
}
}
AUTHOR
Hinrik Oern Sigur`sson, hinrik.sig@gmail.com
perl v5.14.2 2011-12-07 POE::Component::IRC::Cookbook::Seen(3pm)