hi,,
i hav a file with many lines.i need to remove all lines before a line begginning with a specific pattern from the file because these lines are not required.
Can u help me out with either a perl script or shell script
example:-
if file initially contains lines:
a
b
c
d
.1.2
d
e
f... (2 Replies)
Hi Folks,
I got to know from this forums on how to grep from a particular line say line 6
awk 'NR==6 {print;exit}'
But how do i grep from line 6 till the end of the file or command output.
Thanks, (3 Replies)
Hi All,
I have a .txt file with some contents as below:
Hi How are you?
# Fine and you?
I want a script file which reads the .txt file and output the lines which does not start with #.
Hi How are you?
Help is highly appreciated.
Please use code tags when posting data and... (5 Replies)
Hello,
I have a command that show some application information. Now, I have to grep there informations, like:
# showlog | grep 1266
1266.1369866124 ::
1266.1304711286 ::
41031.1161812668 ::
41078.1301266480 ::
41641.712662564 ::
1266.333792515 ::
41462.1512661988 ::
1266.54932671... (5 Replies)
Here is the task that I was presented with:
I am dealing with about a 10,000 line input deck file for an analysis. About 10 separate blocks of around 25 lines of code each need to be updated in the input deck.
The input deck (deckToChange in the code below) comes with 2 separate files. File 1... (5 Replies)
Hi,
I want to read a file line by line and exclude the lines that are beginning with special characters. The below code is working fine except when the line starts with hyphen (-) in the file.
for TEST in `cat $FILE | grep -E -v '#|/+' | awk '{FS=":"}NF > 0{print $1}'`
do
.
.
done
How... (4 Replies)
Hello,
I'm works on Ubuntu server
My goal : I would like to read file line per line, but i want to started at the end of file.
Currently, I use instructions :
while read line;
do
COMMAND
done < /var/log/apache2/access.log
But, the first line, i don't want this. The file is long... (5 Replies)
I have a file with a list of references towards the end and want to apply a grep for some string.
text ....
@unnumbered References
@sp 1
@paragraphindent 0
2017. @strong{Chalenski, D.A.}; Wang, K.; Tatanova, Maria; Lopez,
Jorge L.; Hatchell, P.; Dutta, P.; @strong{Small airgun... (1 Reply)
Shell : bash
OS : RHEL 6.8
I have a file like below.
$ cat pattern.txt
hello
txt1
txt2
txt3
some other text
txt4
I want to remove all lines in this file except the ones starting with txt . How can I do this ? (4 Replies)
Discussion started by: omega3
4 Replies
LEARN ABOUT DEBIAN
file::fu
File::Fu(3pm) User Contributed Perl Documentation File::Fu(3pm)NAME
File::Fu - file and directory objects
SYNOPSIS
The directory constructor:
use File::Fu;
my $dir = File::Fu->dir("bar");
print "$dir
"; # 'bar/'
my $file = $dir + 'bar.txt';
print "$file
"; # 'bar/bar.txt'
my $d2 = $dir % 'baz'; # 'barbaz/'
my $d3 = $dir / 'bat'; # 'bar/bat/'
my $file2 = $dir / 'bat' + 'foo.txt'; # 'bar/bat/foo.txt'
The file constructor:
my $file = File::Fu->file("foo");
$file->e and warn "$file exists";
$file->l and warn "$file is a link";
warn "file is in ", $file->dir;
ABOUT
This class provides the toplevel interface to File::Fu directory and file objects, with operator overloading which allows precise path
composition and support for most builtin methods, as well as creation of temporary files/directories, finding files, and more.
The interface and style are quite different than the perl builtins or File::Spec. The syntax is concise. Errors are thrown with croak(),
so you never need to check a return code.
Constructors
The actual objects are in the 'Dir' and 'File' sub-namespaces.
dir
my $dir = File::Fu->dir($path);
See "new" in File::Fu::Dir
file
my $file = File::Fu->file($path);
See "new" in File::Fu::File
Class Constants
tmp
Your system's '/tmp/' directory (or equivalent of that.)
my $dir = File::Fu->tmp;
home
User's $HOME directory.
my $dir = File::Fu->home;
program_name
The absolute name of your program. This will be relative from the time File::Fu was loaded. It dies if the name is '-e'.
my $prog = File::Fu->program_name;
If File::Fu was loaded after a chdir and the $0 was relative, calling program_name() throws an error. (Unless you set $0 correctly before
requiring File::Fu.)
program_dir
Returns what typically corresponds to program_name()->dirname, but just the compile-time cwd() when $0 is -e/-E.
my $dir = File::Fu->program_dir;
Class Methods
THIS_FILE
A nicer way to say __FILE__.
my $file = File::Fu->THIS_FILE;
cwd
The current working directory.
my $dir = File::Fu->cwd;
which
Returns File::Fu::File objects of ordered candidates for $name found in the path.
my @prog = File::Fu->which($name) or die "cannot find $name";
If called in scalar context, returns a single File::Fu::File object or throws an error if no candidates were found.
my $prog = File::Fu->which($name);
Temporary Directories and Files
These class methods call the corresponding File::Fu::Dir methods on the value of tmp(). That is, you get a temporary file/dir in the
'/tmp/' directory.
temp_dir
my $dir = File::Fu->temp_dir;
temp_file
my $handle = File::Fu->temp_file;
Subclassing
You may wish to subclass File:Fu and override the dir_class() and/or file_class() class methods to point to your own Dir/File subclasses.
my $class = 'My::FileFu';
my $dir = $class->dir("foo");
See File::Fu::File and File::Fu::Dir for more info.
See Also
File::Fu::why if I need to explain my motivations.
Path::Class, from which many an idea was taken.
File::stat, IO::File, File::Spec, File::Find, File::Temp, File::Path, File::Basename, perlfunc, perlopentut.
AUTHOR
Eric Wilhelm @ <ewilhelm at cpan dot org>
http://scratchcomputing.com/
BUGS
If you found this module on CPAN, please report any bugs or feature requests through the web interface at <http://rt.cpan.org>. I will be
notified, and then you'll automatically be notified of progress on your bug as I make changes.
If you pulled this development version from my /svn/, please contact me directly.
COPYRIGHT
Copyright (C) 2008 Eric L. Wilhelm, All Rights Reserved.
NO WARRANTY
Absolutely, positively NO WARRANTY, neither express or implied, is offered with this software. You use this software at your own risk. In
case of loss, no person or entity owes you anything whatsoever. You have been warned.
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2010-05-13 File::Fu(3pm)