Does anyone know how to get these two output lines into one colon ':' separated line with some unix command? Maybe nawk. I've tried to read the nawk and awk man pages but I don't get it right. Are these commands the one to use?
Output from find command:
#
/sw/tools/matlab/7.0.1/man... (2 Replies)
Hi all
i have a data of this form
10.12.4.22:138
10.12.2.50:137
10.20.2.24:1027
10.12.2.44:138
10.12.2.44:137
10.0.4.38:58871
10.13.3.19:138
i need to separate the number out which is at the last and after ':'
Please help me out
Thanx in advance (5 Replies)
Hi,
I have a requirement with,
No~Dt~Notes
1~2011/08/1~"aaa
bbb
ccc
ddd
eee
fff
ggg
hhh"
Single column alone got splitted into multiple lines.
I require the output as
No~Dt~Notes
1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh"
mean to say those new lines to be... (1 Reply)
I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.
example input line:
... (2 Replies)
I have one long line text with semicolon used as separator between values in that line. Now, I want to separate the line into multiple line right after every 29th field.
example input line:
... (1 Reply)
Hi guys,
I have a file which has random records like mentioned below
emcpower28a
pci@3,03 (disk physical name)
pci@3,04
emcpower9a
pci@1,03
pci@2,03
pci@3,01
pci@4,03
there could be any number of disk names for any LUN (emc...) So, I want a solution to count disk names for its... (12 Replies)
Hi,
I want to change a file file1.txt:
1234
3456
2345
6789
3456
2333
4444
As, file2.txt in Linux:
'1234','3456','2345','6789','3456','2333','4444'
Could someone please help me. (Single liner sed, awk will be welcome!) (7 Replies)
Hi Everyone,
On my Linux box I have a text file having block of few lines and this block lines separated by one blank line. I would like to format and print these lines in such a way that this entire block of lines will come as single comma separated line & again next block of lines in next... (7 Replies)
example of problem:
when I echo "$e" >> /home/cogiz/file.txt
result prints to file as:AA
BB
CC
I need it to save to file as this:AA BB CC
I know it's probably something really simple but any help would be greatly appreciated.
Thank You.
Cogiz (7 Replies)
Hi all,
I need help to parse this xml file that has paragraphs broken in different lines and I would like to join in a single line.
I hope you can understand my explanation. Thanks for any help/direction.
The script could be in bash, awk, ruby, perl whatever please
In the output I want:... (8 Replies)
Discussion started by: Ophiuchus
8 Replies
LEARN ABOUT DEBIAN
file::mimeinfo::cookbook
File::MimeInfo::Cookbook(3pm) User Contributed Perl Documentation File::MimeInfo::Cookbook(3pm)NAME
File::MimeInfo::Cookbook - various code snippets
DESCRIPTION
Some code snippets for non-basic uses of the File::MimeInfo module:
Matching an extension
A file does not have to actually exist in order to get a mimetype for it. This means that the following will work:
my $extension = '*.txt';
my $mimetype = mimetype( $extension );
Mimetyping an scalar
If you want to find the mimetype of a scalar value you need magic mimetyping; after all a scalar doesn't have a filename or inode.
What you need to do is to use IO::Scalar :
use File::MimeInfo::Magic;
use IO::Scalar;
my $io_scalar = new IO::Scalar $data;
my $mimetype = mimetype( $io_scalar );
In fact most other "IO::" will work as long as they support the "seek()" and "read()" methods. Of course if you want really obscure
things to happen you can always write your own IO object and feed it in there.
Be aware that when using a filehandle like this you need to set the ":utf8" binmode yourself if apropriate.
Mimetyping a filehandle
Regrettably for non-seekable filehandles like STDIN simply using an "IO::" object will not work. You will need to buffer enough of the
data for a proper mimetyping. For example you could mimetype data from STDIN like this:
use File::MimeInfo::Magic;
use IO::Scalar;
my $data;
read(STDIN, $data, $File::MimeInfo::Magic::max_buffer);
my $io_scalar = new IO::Scalar $data;
my $mimetype = mimetype( $io_scalar );
Be aware that when using a filehandle like this you need to set the ":utf8" binmode yourself if apropriate.
Creating a new filename
Say you have a temporary file that you want to save with a more proper filename.
use File::MimeInfo::Magic qw#mimetype extensions#;
use File::Copy;
my $tmpfile = '/tmp/foo';
my $mimetype = mimetype($tmpfile);
my $extension = extensions($mimetype);
my $newfile = 'untitled1';
$newfile .= '.'.$extension if length $extension;
move($tmpfile, $newfile);
Force the use of a certain database directory
Normally you just need to add the dir where your mime database lives to either the XDG_DATA_HOME or XDG_DATA_DIRS environment variables
for it to be found. But in some rare cases you may want to by-pass this system all together. Try one of the following:
@File::MimeInfo::DIRS = ('/home/me/share/mime');
eval 'use File::MimeInfo';
die if $@;
or:
use File::MimeInfo;
@File::MimeInfo::DIRS = ('/home/me/share/mime');
File::MimeInfo->rehash();
This can also be used for switching between databases at run time while leaving other XDG configuration stuff alone.
AUTHOR
Jaap Karssenberg <pardus@cpan.org>
Copyright (c) 2005, 2012 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
File::MimeInfo
perl v5.14.2 2012-01-05 File::MimeInfo::Cookbook(3pm)