02-27-2009
Quote:
Originally Posted by
adderek
If the line can be very long you could expect unexpected problems (like storing too much data into a variable in shell or the line being truncated).
There is no reason either should happen. The variable length is limited only by available memory.
Quote:
On the other side such trick could probably work as well: "for var in $(cat file); do .... done"
The is not the way to read a file. It sets var to each word in the file, not each line.
Quote:
or better - use "read".... you might need to play with the FS/IFS settings.
There is no need to play with IFS to read a file line by line.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi
i am new to shelll scripting
I need to parse a string like "abc,def,ghie,jkl"
And assign them to some variables like
hs1 = abc
hs2 = def
hs3 = ghi
hs4 = jkl
Please help (4 Replies)
Discussion started by: satish@123
4 Replies
2. Shell Programming and Scripting
#! /usr/local/bin/perl -w
$ip = "$ARGV";
$rw = "$ARGV";
$snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw";
$snmpw = "/usr/local/bin/snmpwalk -Os -c $rw";
$syst=`$snmpg $ip system sysName sysObjectID`;
sysDescr.0 = STRING: Cisco Internetwork Operating System Software... (1 Reply)
Discussion started by: popeye
1 Replies
3. Shell Programming and Scripting
My file will contain following(log.txt):
start testcase: config loading
......
error XXXX
.....
end testcase: config loading, result failed
start testcase: ping check
.....
error ZZZZZ
.....
error AAAAA
end testcase: Ping check, result failed
I am expecting below output. ... (4 Replies)
Discussion started by: shellscripter
4 Replies
4. Shell Programming and Scripting
I need the perl solution for the following :
$string="I LOVE INDIA"
now, in a new string i need the first character of each word...
that is string2 should be "ILN". (10 Replies)
Discussion started by: vijay_0209
10 Replies
5. Shell Programming and Scripting
Hi,
name=VDSL_TTV_ HN_SUB create coid=MA5603U phone=5678 portpolicy=APortSelectionPolicy rfu10=TTV rfu3=Dot1q sz7_portmode=VDSL2 rfu5=1234 srprofile.sy_profname=$ADSL_TTV_SubProfile1
I have a line like this. Its a single line.I need the output as
name=VDSL_TTV_ HN_SUB create... (1 Reply)
Discussion started by: giri_luck
1 Replies
6. Shell Programming and Scripting
for i in `cat list`;do lol=`curl -m 2 -s ${i} | grep 'class=info' | cut -d '>' -f14 | cut -d '<' -f1 | sed '/^$/d'`; if ;then echo "$i,$lol" >> dirty; echo "$i,$lol";fi; done
cut: you must specify a list of bytes, characters, or fields
Try `cut --help' for more information.
it gave me that... (0 Replies)
Discussion started by: p33plime
0 Replies
7. Shell Programming and Scripting
Hi everyone,
I am working on fetchmail + procmail to filter mails and I am having problem with parsing a long line in the body of the email.
Could anyone help me construct a reg exp for this string below. It needs to match exactly as this string.
GetRyt... (4 Replies)
Discussion started by: cwiggler
4 Replies
8. Shell Programming and Scripting
Hello all;
lat week I was able to get some assistance on creating a summary report from a file generated by a "comm" comparison of twp CSV files...turn out now that I am being asked for a detail report as well...this is beyond my knowledge of perl (and yes I have to use perl)..also please keep... (5 Replies)
Discussion started by: gvolpini
5 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I need some advise on how to print 'sections' of the attached file. I am searching for some that says Marked Corrupt and print some lines after it.
At the moment I am running the command below:
sed -n -e '/Marked Corrupt/{N;N;p;}' rman_list_validate.txtThis gives me the following... (1 Reply)
Discussion started by: newbie_01
1 Replies
10. Shell Programming and Scripting
The log file is huge and lot of information, i would like to parse and make a report .
below is the log file looks like:
REPORT DATE: Mon Aug 10 04:16:17 CDT 2017
SYSTEN VER: v1.3.0.9
TERMINAL TYPE: prod
SYSTEM: nb11cu51
UPTIME: 04:16AM up 182 days 57 mins min
MODEL, TYPE, and SN:... (8 Replies)
Discussion started by: amir07
8 Replies
LEARN ABOUT DEBIAN
hxnormalize
HXNORMALIZE(1) HTML-XML-utils HXNORMALIZE(1)
NAME
hxnormalize - pretty-print an HTML file
SYNOPSIS
hxnormalize [ -x ] [ -e ] [ -d ] [ -s ] [ -L ] [ -i indent ] [ -l line-length ] [ -c commentmagic ] [ file-or-URL ]
DESCRIPTION
The hxnormalize command pretty-prints an HTML file, and also tries to fix small errors. The output is the same HTML, but with a maximum
line length and with optional indentation to indicate the nesting level of each line.
OPTIONS
The following options are supported:
-x Use XML conventions: empty elements are written with a slash at the end: <IMG />. Implies -e.
-e Always insert endtags, even if HTML does not require them (for example: </p> and </li>).
-d Omit the DOCTYPE from the output.
-i indent Set the number of spaces to indent each nesting level. Default is 2. Not all elements cause an indent. In general, elements that
can occur in a block environment are started on a new line and cause an indent, but inline elements, such as EM and SPAN do not
cause an indent.
-l line-length
Sets the maximum length of lines. hxnormalize will wrap lines so that all lines are as long as possible, but no longer than this
length. Default is 72. Words that are longer than the line length will not be broken, and will extend past this length. A
content of the STYLE, SCRIPT and PRE elements will not be line-wrapped.
-s Omit <span> tags that don't have any attributes.
-L Remove redundant "lang" and "xml:lang" attributes. (I.e., those whose value is the same as the language inherited from the parent
element.)
-c commentmagic
Comments are normally placed right after the preceding text. That is usually correct for short comments, but some comments are
meant to be on a separate line. commentmagic is a string and when that string occurs inside a comment, hxnormalize will output
an empty line before that comment. E.g. -c "====" can be used to put all comments that contain "====" on a separate line, pre-
ceded by an empty line. By default, no comments are treated that way.
OPERANDS
The following operand is supported:
file-or-URL
The name or URL of an HTML file. If absent, standard input is read instead.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
> 0 An error occurred in the parsing of the HTML file. hxnormalize will try to correct the error and produce output anyway.
ENVIRONMENT
To use a proxy to retrieve remote files, set the environment variables http_proxy and ftp_proxy. E.g., http_proxy="http://localhost:8080/"
BUGS
The error recovery for incorrect HTML is primitive.
hxnormalize will not omit an endtag if the white space after it could possibly be significant. E.g., it will not remove the first </p> from
"<div><p>text</p> <p>text</p></div>".
hxnormalize can currently only retrieve remote files over HTTP. It doesn't handle password-protected files, nor files whose content depends
on HTTP "cookies."
SEE ALSO
asc2xml(1), xml2asc(1), UTF-8 (RFC 2279)
6.x 10 Jul 2011 HXNORMALIZE(1)