If the first line of input happens to start with a plus sign, all of the scripts provided so far will skip that line. If the input file could ever have this condition, the following alternative script should work:
With the sample input file hanson44 provided, the output placed into file2 will be:
If the contents of file1 is:
the output placed into file2 will be:
As always, if you're going to run this on a Solaris/SunOS system, use /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk instead of awk.
Hi
Is there any command or a trick that can take me to a specifed line number in unix .
Suppose i have a file with 2000 lines and i would like to go to line number 1899 and then print out the contents of the line.
regards
Hrishy (2 Replies)
Hi ,
I use read command to get the input text, When i try to get the line starting with spaces or ending with spaces it automatically truncates the spaces and displays the remaining content.
Code i tried (UserInput.sh):
#!/bin/bash
echo -n "Enter some text > "
read text
echo "You... (3 Replies)
Whenever I type the @ sign like for example when using a proxy ftp server, The system forces the cursor to jump to a new line. I know it has something to do with the terminal settings.
How can I get this to stop and more importantly, how can I modify my profile to set this up whenever I login?
... (3 Replies)
echo "dddd$dddd"|sed 's/$//' will return dddd
echo "dddd$ddd"|tr -d '$' will return dddd
I need to replace it with any other character or just live a blank space instead
Thank you! (8 Replies)
Hi,
Let's I have the following strings (md5):
07177edf8261d28c6a003e583fcbe38c
0717c0037b3a20fc0f0998e673f228d5
0717d611a5d24374628b98e17fd00977,0717d611a5d24374628b98e17fd00977
07189a18afdae558bb5aadfe602e4a91
0719e97d481c239667f38a3e166bed74
071af3225fe50a1fdbb42c43aac313cc... (4 Replies)
I have a file with different directories in it. I would need to move one line within the file to the end of the list. Also not there could be blank line in the middle of it. Example
/vol/fs1
/vol/fs2
/vol/fs3
/vol/fs4
/vol/fs5
/vol/fs6
/vol/fs7
So I would need /vol/fs2... (3 Replies)
example:
comment Now_TB.table column errac is for error messages
1 - first
2 - second
3 -third ;
in this example I need to be able to grab the comment as first word and ; as the last word and it might span a few lines. I need it to be put all in one line without line breaks so I can... (4 Replies)
Hello.
Using a bash script , I have a variable name for the file I want to modify
FILE_TO_EDIT="/etc/my_config_file"And I have a variable name for the parameter to change
PARAMETER="fallback_node"
PARAMETER_NEW_VALUE="http://my_server_name.com/new_path"
A config file may contain :
1°)... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data: It's a shell script using a looping logic, trap, tput, if, while. Most of the scripts in this book aren't written... (2 Replies)
POE::Filter::Line(3pm) User Contributed Perl Documentation POE::Filter::Line(3pm)NAME
POE::Filter::Line - serialize and parse terminated records (lines)
SYNOPSIS
#!perl
use POE qw(Wheel::FollowTail Filter::Line);
POE::Session->create(
inline_states => {
_start => sub {
$_[HEAP]{tailor} = POE::Wheel::FollowTail->new(
Filename => "/var/log/system.log",
InputEvent => "got_log_line",
Filter => POE::Filter::Line->new(),
);
},
got_log_line => sub {
print "Log: $_[ARG0]
";
}
}
);
POE::Kernel->run();
exit;
DESCRIPTION
POE::Filter::Line parses stream data into terminated records. The default parser interprets newlines as the record terminator, and the
default serializer appends network newlines (CR/LF, or "x0Dx0A") to outbound records.
Record terminators are removed from the data POE::Filter::Line returns.
POE::Filter::Line supports a number of other ways to parse lines. Constructor parameters may specify literal newlines, regular
expressions, or that the filter should detect newlines on its own.
PUBLIC FILTER METHODS
POE::Filter::Line's new() method has some interesting parameters.
new
new() accepts a list of named parameters.
In all cases, the data interpreted as the record terminator is stripped from the data POE::Filter::Line returns.
"InputLiteral" may be used to parse records that are terminated by some literal string. For example, POE::Filter::Line may be used to
parse and emit C-style lines, which are terminated with an ASCII NUL:
my $c_line_filter = POE::Filter::Line->new(
InputLiteral => chr(0),
OutputLiteral => chr(0),
);
"OutputLiteral" allows a filter to put() records with a different record terminator than it parses. This can be useful in applications
that must translate record terminators.
"Literal" is a shorthand for the common case where the input and output literals are identical. The previous example may be written as:
my $c_line_filter = POE::Filter::Line->new(
Literal => chr(0),
);
An application can also allow POE::Filter::Line to figure out which newline to use. This is done by specifying "InputLiteral" to be undef:
my $whichever_line_filter = POE::Filter::Line->new(
InputLiteral => undef,
OutputLiteral => "
",
);
"InputRegexp" may be used in place of "InputLiteral" to recognize line terminators based on a regular expression. In this example, input
is terminated by two or more consecutive newlines. On output, the paragraph separator is "---" on a line by itself.
my $paragraph_filter = POE::Filter::Line->new(
InputRegexp => "([x0Dx0A]{2,})",
OutputLiteral => "
---
",
);
PUBLIC FILTER METHODS
POE::Filter::Line has no additional public methods.
SEE ALSO
Please see POE::Filter for documentation regarding the base interface.
The SEE ALSO section in POE contains a table of contents covering the entire POE distribution.
BUGS
The default input newline parser is a regexp that has an unfortunate race condition. First the regular expression:
/(x0Dx0A?|x0Ax0D?)/
While it quickly recognizes most forms of newline, it can sometimes detect an extra blank line. This happens when a two-byte newline
character is broken between two reads. Consider this situation:
some stream dataCR
LFother stream data
The regular expression will see the first CR without its corresponding LF. The filter will properly return "some stream data" as a line.
When the next packet arrives, the leading "LF" will be treated as the terminator for a 0-byte line. The filter will faithfully return this
empty line.
It is advised to specify literal newlines or use the autodetect feature in applications where blank lines are significant.
AUTHORS & COPYRIGHTS
Please see POE for more information about authors and contributors.
perl v5.14.2 2012-05-15 POE::Filter::Line(3pm)