Recent Topics

1 Jul 05, 2007 15:59    

My b2evolution Version: Not Entered

This isn't the first time i have got jacked up by this. Our blog we like to reference alot of code and tech stuff but too many errors posting. Is there a quick fix?

THE ERROR:

Invalid post, please correct these errors:

Parser error: XML_ERR_NAME_REQUIRED near linecount="$(($linec

THE TEXT IN POST:

The Code
#!/bin/sh

# numberlines - A simple alternative to cat -n, etc.

for filename
do
  linecount="1"
  while read line
  do
    echo "${linecount}: $line"
    linecount="$(($linecount + 1))"
  done < $filename
done
exit 0

Running the Script
You can feed as many filenames as you want to this script, but you can't feed it input via a pipe, though that wouldn't be too hard to fix, if needed.

The Results
$ numberlines text.snippet.txt
1: Perhaps one of the most valuable uses of shell scripts is to fix
2: your particular flavor of Unix and make it more like other flavors,
3: to bring your commands into conformance or to increase consistency
4: across different systems. The outsider view of Unix suggests a
5: nice, uniform command-line experience, helped along by the existence
6: of and compliance with the POSIX standards for Unix. But anyone who's
7: ever touched more than one computer knows how much they can vary
8: within these broad parameters.


Form is loading...