03-31-2008
You have been reading shell programming tutorials (and possibly C shell, if they advice round parentheses in the if -- that's different from Bourne shell, sort of like Java is quite unlike JavaScript, although not quite as unrelated) but the program you have written is in the awk language, which is not at all the same thing. Compare to how you can use a DLL written in another language from a C program. But with scripts, the source can be in two different languages, and often is -- you frequently put small awk or sed or Perl or TCL or ... other scripts in shell scripts where the shell's own syntax or facilities don't match the problem space well enough.
The Perl program does what I imagine your spec says it should do. Try it and see. It replaces multiples of 119 charactes or less followed by a space or a comma with the same string plus a backslash and a newline. You could do the same in sed or awk, albeit not quite as succinctly; the main concept here is a regular expression, which is a facility all of these languages provide. (I think you have it in VB, too, and there are C libraries you can link to if you like.) Read up on that, it's an extremely useful and versatile tool, quite independent of any particular language.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have a case where, I need to look into a file.
Go to each line of the file, find the length of the line, if the length of the line is more than 75 chars, I need to split the line into multiple lines of 75chars max. If the length of the line is less than 75, we need not do anything.
So at the... (4 Replies)
Discussion started by: thanuman
4 Replies
2. Shell Programming and Scripting
Hi all
I have a file with these lines
good
gone
home
What code do you need to put this on one line like this
good gone home (2 Replies)
Discussion started by: hawaiifiver
2 Replies
3. Shell Programming and Scripting
Hi,
I've some files with the following data and i need to convert the lines between the separator ---, into a single line. I've tried with the paste cmd but my main problem is that the number of lines between the separator is not fix, it can very between 1-4 lines.
Input
---
2010-02-22... (4 Replies)
Discussion started by: RickyC9999
4 Replies
4. Shell Programming and Scripting
Hi,
I have a huge file with a single line.
But I want to break that line into lines of with each line having five columns.
My file is like this:
code:
"hi","there","how","are","you?","It","was","great","working","with","you.","hope","to","work","you."
I want it like this:
code:... (1 Reply)
Discussion started by: rajsharma
1 Replies
5. Shell Programming and Scripting
example:
comment Now_TB.table column errac is for error messages
1 - first
2 - second
3 -third ;
in this example I need to be able to grab the comment as first word and ; as the last word and it might span a few lines. I need it to be put all in one line without line breaks so I can... (4 Replies)
Discussion started by: wambli
4 Replies
6. Shell Programming and Scripting
Hi guys,
So i have a input file with several sequences aligned (fasta)
>NC_005930 241 bp
MNMINIFIINNIFDQFIPVKLSIFSLTSVGSIIA
LSWVWINTKTHWAISRSNTP-SLLLNSL
WTLLITNL-NEKTNPWAPWLFSLFLLCFSFNIMSLI-PYTF-SQ
TSHLSFTFGLSLPIWIMVNIAGFKNNWKKKISHLLPQGTPIYLVPVMII
IETISLFIQPLTLGFRLGANLLAGHLLIFLCSCTIWE... (6 Replies)
Discussion started by: andreia
6 Replies
7. Shell Programming and Scripting
Hi All,
I am reading a line from a file and writing it to other file.
Whenever I got a particular line then I want that line to be splited into 4 line and written it to new file. e.g My line is
U_ABC connector3 pin24E connector4 pin25E connector5 pin26E connector6 pin27E connector7... (2 Replies)
Discussion started by: diehard
2 Replies
8. Shell Programming and Scripting
Hi,
I have one problem scenorio as below.
my source file is :
cat input_file.
"hi","there","how","are","you?","It","was","great","working","with","you.","hope","to","work","y ou."
my output should be like.
"hi","there","how","are","you?",
"It","was","great","working","with",... (7 Replies)
Discussion started by: abhilash_nakka
7 Replies
9. Shell Programming and Scripting
Hi All,
I have more than half million lines of XML file , wanted to split in four files in a such a way that top 7 lines should be present in each file on top and bottom line of should be present in each file at bottom.
from the 8th line actual record starts and each record contains 15 lines... (14 Replies)
Discussion started by: ajju
14 Replies
10. UNIX for Beginners Questions & Answers
I have code as below
# create temporary table `temp4277`(key(waybill_no))
select waybill_no,concat_ws('',card_type,card_series_no) cardinfo
from rfid_temp_ticket where waybill_no='4277'
group by... (4 Replies)
Discussion started by: kaushik02018
4 Replies
FMT(1) FSF FMT(1)
NAME
fmt - simple optimal text formatter
SYNOPSIS
fmt [-DIGITS] [OPTION]... [FILE]...
DESCRIPTION
Reformat each paragraph in the FILE(s), writing to standard output. If no FILE or if FILE is `-', read standard input.
Mandatory arguments to long options are mandatory for short options too.
-c, --crown-margin
preserve indentation of first two lines
-p, --prefix=STRING
combine only lines having STRING as prefix
-s, --split-only
split long lines, but do not refill
-t, --tagged-paragraph
indentation of first line different from second
-u, --uniform-spacing
one space between words, two after sentences
-w, --width=NUMBER
maximum line width (default of 75 columns)
--help display this help and exit
--version
output version information and exit
In -wNUMBER, the letter `w' may be omitted.
AUTHOR
Written by Ross Paterson.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU-
LAR PURPOSE.
SEE ALSO
The full documentation for fmt is maintained as a Texinfo manual. If the info and fmt programs are properly installed at your site, the
command
info fmt
should give you access to the complete manual.
fmt (coreutils) 4.5.3 February 2003 FMT(1)