The definition of how file decides on filetype is:
from man file, q.v.
One could create one's own file command and add the GS control character as an exception -- I have not done it, but I think the file magic could be so changed. Otherwise, one could replace the GS (say with sed) to something innocuous before feeding the resulting copy of the data file to the file commend.
Hi All
I am simulating a problem in the production where i faced a situation.
Please find the following example program which i simulated.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char str1; (3 Replies)
i have no idea abount shell script but i need need shell script to get last 10 char from a file name and write in to a new file.
consider u hav 5 files in a particular dir i script should get last 10 char of each file n write the 10 char in separate files (2 Replies)
I've this file and need to sort the data in each group
File would look like this ...
cat file1.txt
Reason : ABC
12345-0023
32123-5400
32442-5333
Reason : DEF
42523-3453
23345-3311
Reason : HIJ
454553-0001
I would like to sort each group on the last 4 fileds and print them... (11 Replies)
Hi all,
I'm reading a file with this layout:
First_Col Second_Col
The Second_Col has values as 1000, -1, 10, 43...
While reading the file I'm getting the second column value with awk command, but it is including the CR control char.
do
item_saved=`echo $b | awk '{print... (4 Replies)
hi
I have the below code to convert hexa to binary. It is working fine, but i want to store the binary in char or int. The below program is printing the result.
void ConvertHexToBinary(char sHexValue)
{
int i;
printf("Binary Equivalent=");
for(i=0;sHexValue!=NULL;i++)
{
... (1 Reply)
Hi
I am using sed command to make SCORE=somevalue to SCORE=blank in a file.
Please see the attached lastline.txt file. After executing the below command on the file, it removes the last line.
cat lastline.txt | sed 's/SCORE=.*$/SCORE=/g' > newfile.txt
Why does sed command remove the... (3 Replies)
I am trying to add a unique identifier to two file extensions .bam and .vcf in a directory located at /home/cmccabe/Desktop/index/R_2016_09_21_14_01_15_user_S5-00580-9-Medexome.
The identifier is in $2 of the input file. What the code below is attempting to do is strip off the last portion... (21 Replies)
Unix File is pipe delimited with 17 fields. We may get extra pipes in data also.
We may get \n char (1 or more \n in one field or multi fileds) in data in any field.
Need to replace \n true ( line separator) with 'space and bell char space' chars (' \a ') Not data \n.
Input:... (1 Reply)
Discussion started by: rajeshkumare
1 Replies
LEARN ABOUT DEBIAN
file::countlines
File::CountLines(3pm) User Contributed Perl Documentation File::CountLines(3pm)NAME
File::CountLines - efficiently count the number of line breaks in a file.
SYNOPSIS
use File::CountLines qw(count_lines);
my $no_of_lines = count_lines('/etc/passwd');
# other uses
my $carriage_returns = count_lines(
'path/to/file.txt',
style => 'cr',
);
# possible styles are 'native' (the default), 'cr', 'lf'
DESCRIPTION
perlfaq5 answers the question on how to count the number of lines in a file. This module is a convenient wrapper around that method, with
additional options.
More specifically, it counts the number of line breaks rather than lines. On Unix systems nearlly all text files end with a newline (by
convention), so usually the number of lines and number of line breaks is equal.
Since different operating systems have different ideas of what a newline is, you can specifiy a "style" option, which can be one of the
following values:
"native"
This takes Perl's "
" as the line separator, which should be the right thing in most cases. See perlport for details. This is the
default.
"cr"
Take a carriage return as line separator (MacOS style)
"lf"
Take a line feed as line separator (Unix style)
"crlf"
Take a carriage return followed by a line feed as separator (Microsoft Windows style)
Alternatively you can specify an arbitrary separator like this:
my $lists = count_lines($file, separator => 'end{itemize}');
It is taken verbatim and searched for in the file.
The file is read in equally sized blocks. The size of the blocks can be supplied with the "blocksize" option. The default is 4096, and can
be changed by setting $File::CountLines::BlockSize.
Do not use a block size smaller than the length of the separator, that might produce wrong results. (In general there's no reason to chose
a smaller block size at all. Depending on your size a larger block size might speed up things a bit.)
Character Encodings
If you supply a separator yourself, it should not be a decoded string.
The file is read in binary mode, which implies that this module works fine for text files in ASCII-compatible encodings, including ASCII
itself, UTF-8 and all the ISO-8859-* encodings (aka Latin-1, Latin-2, ...).
Note that the multi byte encodings like UTF-32, UTF-16le, UTF-16be and UCS-2 encode a line feed character in a way that the 0x0A byte is a
substring of the encoded character, but if you search blindly for that byte you will get false positives. For example the LATIN CAPITAL
LETTER C WITH DOT ABOVE, U+010A has the byte sequence "0x0A 0x01" when encoded as UTF-16le, so it would be counted as a newline. Even
search for "0x0A 0x00" might give false positives.
So the summary is that for now you can't use this module in a meaningful way to count lines of text files in encodings that are not ASCII-
compatible. If there's demand for, I can implement that though.
Extending
You can add your own EOL styles by adding them to the %File::CountLines::StyleMap hash, with the name of the style as hash key and the
separator as the value.
AUTHOR
Moritz Lenz <http://perlgeek.de>, <mailto:moritz@faui2k3.org>
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Moritz A. Lenz. This module is free software. You may use, redistribute and modify it under the same terms as perl
itself.
Example code included in this package may be used as if it were in the Public Domain.
DEVELOPMENT
You can obtain the latest development version from <http://github.com/moritz/File-CountLines>:
git clone git://github.com/moritz/File-CountLines.git
perl v5.10.1 2010-08-19 File::CountLines(3pm)