Sponsored Content
Top Forums Shell Programming and Scripting while read loop preserving leading whitespace Post 51995 by zazzybob on Monday 7th of June 2004 05:36:06 PM
Old 06-07-2004
Just thought I'd let everyone know that I decided to implement this in awk in the end, as processing the syntax of a gazillion shell scripts is easier to do with awk. As $0 can just be processed the way I wanted leaving whitespace intact using "\n" as the RS.

I am writing a script which will convert shell syntax to colour-highlighted HTML. I found scripts to do this for just about every language EXCEPT for humble old SH so I decided to do it myself! You can view a sample output from the script HERE . The script itself is still under test and thus is not yet online.

Sorry for the "shameless plug" but I thought I'd let everybody know what the purpose of my original post was.

Peace
ZB

Last edited by zazzybob; 06-07-2004 at 06:54 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh - read file with leading spaces

Hi, Could someone has any suggestions on this? When read a line from a file, I need to check the first char in the line, it could be a space or any char. But the leading spaces are removed by read. Thanks. (2 Replies)
Discussion started by: momi
2 Replies

2. Shell Programming and Scripting

Preserving whitespace in a for loop

I obviously haven't learned my lesson with shell and whitespace. find /path/to/some/where/ -name "*.pdf" | awk '{print $5}'| uniq -d results: some Corporation other Corporate junk firmx Works fine from cmdline but the whitespace turns into another FS in a for loop. for... (7 Replies)
Discussion started by: s_becker
7 Replies

3. Shell Programming and Scripting

Whitespace in filenames in for loop in bash script

I'm trying to search all .odt files in a directory for a string in the text of the file. I've found a bash script that works, except that it can't handle whitespace in the filenames. #!/bin/bash if ; then echo "Usage: searchodt searchterm" exit 1 fi for file in $(ls *.odt); do ... (4 Replies)
Discussion started by: triplemaya
4 Replies

4. Shell Programming and Scripting

Preventing whitespace to be a delimiter in a for loop (bash/sh)

Hi, I have a for loop which iterates over a list of strings, separated by whitespace: $ list="1 2 3" $ for i in $list; do echo $i; done 1 2 3 I now want to introduce some strings containing whitespace themselves ... This is straightforward if I directly iterate over the list: $ for... (4 Replies)
Discussion started by: kkkoehne
4 Replies

5. Shell Programming and Scripting

How to match (whitespace digits whitespace) sequence?

Hi Following is an example line. echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:" I want it's output to be 200 However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies

6. Shell Programming and Scripting

Preserving values with for loop for later use

Below is the issue I am having. I have a few variables which have certain values in them like var1=23 var2=46 var3=78 etc... I want to save these values with the help of a for loop in a single variable so that I can use it later,beacuse a few lines down the script, some of these... (3 Replies)
Discussion started by: Elizabeth H
3 Replies

7. UNIX for Dummies Questions & Answers

[Solved] How remove leading whitespace from xml (sed /awk?)

Hi again I have an xml file and want to remove the leading white space as it causes me issues later in my script I see sed is possible but cant seem to get it to work I tried sed 's/^ *//' file.xml output <xn:VsDataContainer id="1U104799" modifier="update"> ... (10 Replies)
Discussion started by: aniquebmx
10 Replies

8. Shell Programming and Scripting

Read line, issue with leading - and {}'s

Heyas With my forum search term 'issue with leading dash' i found 2 closed threads which sadly didnt help me. Also me was to eager to add the script, that i didnt properly test, and just now figured this issue. So i have this code: if ] then while read line do line="${line/-/'\-'}"... (7 Replies)
Discussion started by: sea
7 Replies

9. Shell Programming and Scripting

[BASH] read 'line' issue with leading tabs and virtual line breaks

Heyas I'm trying to read/display a file its content and put borders around it (tui-cat / tui-cat -t(ypwriter). The typewriter-part is a 'bonus' but still has its own flaws, but thats for later. So in some way, i'm trying to rewrite cat using bash and other commands. But sadly it fails on... (2 Replies)
Discussion started by: sea
2 Replies

10. Shell Programming and Scripting

REGEX to separate paths by whitespace and do a loop

I am trying to do in a single line to take a list of paths separated by whitespace and then loop thru all the paths that were wrote but my regex is not working, I have echo {3} | sed 's/ //g' | while read EACHFILE do ..... But for some reason is only taking always the first path that I... (7 Replies)
Discussion started by: jorgejac
7 Replies
SIMPLIFY(1)						      General Commands Manual						       SIMPLIFY(1)

NAME
simplify - a script to simplify a MIME message SYNOPSIS
simplify [args ...] < message > othermessage DESCRIPTION
This manual page documents briefly the simplify command. simplify is a Perl script to simplify a MIME message. This script never loads the entire message into memory, but does dump it's entire contents to disk once. OPTIONS
mime=no Don't use MIME, no HTML mail allowed. testing=yes Run in testing mode (suppress randonmess) saveall=yes Save all attachments to files. temp=/path/to/working/dir/ Defaults to /tmp. url=http://box/path/ URL-prefix for printing paths to attachments header=text... Text preceding the attachment URL list. textsig=/path/to/file Text signature to append to text parts. htmlsig=/path/to/file HTML signature to append to HTML parts. If "saveall" is yes, then the script will save all attachments to disk so people can access their contents later. If an URL is specified then that automatically implies "saveall=yes". Without this, the default behavior is to only save text and html parts, and delete them and all working directories when the script is finished. SEE ALSO
sanitizer(1). More info on configuration: /usr/share/doc/sanitizer/sanitizer.html AUTHOR
Bjarni R. Einarsson <bre@klaki.net> This manual page was written by Alberto Gonzalez Iniesta <agi@agi.as> for the Debian GNU/Linux system (but may be used by others). May 14, 2003 SIMPLIFY(1)
All times are GMT -4. The time now is 11:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy