Sponsored Content
Top Forums UNIX for Dummies Questions & Answers file feed one line per argument Post 8274 by jpprial on Tuesday 9th of October 2001 09:48:51 AM
Old 10-09-2001
I see that it works. But somehow I have to count the empty fields, to make sure that there are 4 fields, empty or not. I tried adding an "or" to the test statement (for fields 2 and 4, which can be blank), like this:

[[ ! -z $rstate -o -z $rstate ]] && ((nf=nf+1))

but it complains about the -o option.

This is the test I put for length of id field,
thanks again.

idlength=${#id}

if [ $idlength -ne 0 -a $idlength -le 4 ]; then
:
else
echo "id field must be from 1 to 4 characters"
fi

I also need some way to put the line number of a failing line into an echo statement...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing Carriage Return and or line feed from a file

Hello I'm trying to write a shell script which can remove a carriage return and/or line feed from a file, so the resulting file all ends up on one line. So, I begin with a file like this text in file!<CR> line two!<CR> line three!<CR> END!<CR> And I want to end up with a file... (1 Reply)
Discussion started by: tbone231
1 Replies

2. Shell Programming and Scripting

Unable to display correctly the contents of a file without a line feed

I am using AIX and ksh. I need to display the contents of a file that has a pid (process id). Because the file is open, it doesn't have the line feed or new line, so for some reason if I do this: `cat $pid` , where $pid is the name of the fully qualified file, it displays test3.sh: 426110:... (1 Reply)
Discussion started by: Gato
1 Replies

3. Shell Programming and Scripting

replace last form feed with line feed

Hi I have a file with lots of line feeds and form feeds (page break). Need to replace last occurrence of form feed (created by - echo "\f" ) in the file with line feed. Please advise how can i achieve this. TIA Prvn (5 Replies)
Discussion started by: prvnrk
5 Replies

4. Shell Programming and Scripting

Get the 1st 99 characters and add new line feed at the end of the line

I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed). AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC MY * A02 RESALE 6990788000 Y... (3 Replies)
Discussion started by: udelalv
3 Replies

5. Shell Programming and Scripting

Remove line feed from csv file column

Hi All, My requirement is to remove line (3 Replies)
Discussion started by: r_t_1601
3 Replies

6. Shell Programming and Scripting

Remove line feed from csv file column

Hi All, i have a csv file . In the 7th column i have data that has line feed in it. Requirement is to remove the line feed from the 7th column whenever it appears There are 11 columns in the file C1,C2,C3,C4,C5,C6,C7,C8,C9,C10,C11 The value in C7 contains line feed ( Alt + Enter ),... (2 Replies)
Discussion started by: r_t_1601
2 Replies

7. Shell Programming and Scripting

Delete a specific line from the feed file

Hi All, I have came across an issue where I will grep for a primary key and then I have to delete that particular line from the feed file and then save it. The feed file is a TAB delimited one. For example: grep 539439AE9 file1 100.00000 20090119 20090119 20090521 ... (4 Replies)
Discussion started by: filter
4 Replies

8. Shell Programming and Scripting

Help in removing control M and Line feed in output file.

Hi All, In my output file i am getting control m character and also the line feeds at different places and with different combinations, the content of the file is supposed to be in a single line but if there is a line feed in between then from there onwards it's going into new line. I tried... (7 Replies)
Discussion started by: Bipin Kumar
7 Replies

9. Shell Programming and Scripting

Want to remove a line feed depending on number of tabs in a line

Hi! I have been struggling with a large file that has stray end of line characters. I am working on a Mac (Lion). I mention this only because I have been mucking around with fixing my problem using sed, and I have learned far more than I wanted to know about Unix and Mac eol characters. I... (1 Reply)
Discussion started by: user999991
1 Replies

10. Shell Programming and Scripting

awk issue splitting a fixed-width file containing line feed in data

Hi Forum. I have the following script that splits a large fixed-width file into smaller multiple fixed-width files based on input segment type. The main command in the script is: awk -v search_col_pos=$search_col_pos -v search_str_len=$search_str_len -v segment_type="$segment_type"... (8 Replies)
Discussion started by: pchang
8 Replies
ACHECK-RULES.5(5)					User Contributed Perl Documentation					 ACHECK-RULES.5(5)

NAME
set.rules - Rules set for acheck DESCRIPTION
Rules set files contain rules to be check by acheck. Lines beginning with a number sign (`#') and empty lines will be ignored. Spaces at the beginning and the end of a line will also be ignored as well as tabulators. If you need spaces at the end or the beginning of a value you can use apostrophes (`"'). A comment starts with the number sign, there can be any number of spaces and/or tab stops in front of the #. Long lines can be broken into multiple lines ending with a backslash (`'). Some possible examples: # this line is ignored field value field value # this is a comment field "value ending with space " field value continuing on the next line You have to escape number signs with a backslash to use it in a value and use apostrophes if a value ends with a backslash. Rule sets are made of lists of rules. Theses lists can be repeated a number of times, until or while a condition happens. A rule detects an error if the corresponding test succeeds and none of its validation tests does. Each rule can then produce some fixes, a warning or an error, and provide hints to help the operator to correct the error. Parts of the text can be set as comments and so no rule and no spell check will be performed on them. RULE FILE SYNTAX
SYNTAX RULES
list A list starts at a `list' statement, and stops at the first `end_list' or at the end of the file. Mandatory fields: type type until, perform the list until the current line matches `test' while, perform the lint while the current line matches `test' loop, perform the list `test' times test regex / number A regex for `until' and `while' lists. The number of times the list must be performed for `loop', or `0' for infinite loop. Optional fields: name name Use this to give the list a name. spell yes / no Set it to `yes' (default) or `no', if you want or don't want spelling to be checked in the lines matching this list. This value will be inherited by the nested lists. Sub-rules: list [name] rule [name] comment [name] Followed by the name of the sub-rule or its definition for an anonymous sub-rule. rule A rule starts at a `rule' statement, and stops at the first `end_rule' or at the beginning of a comment or a list. Mandatory fields: type type fix, rule provides fixes and hints thought a menu autofix, rule fixes the mistake with no interaction warning, rule issues a warning error, rule issues an error nop, special rule that do nothing, no other field is required regex regex The regex to be match to found this error. Patterns can be captures and then used in the `fix' expression. fix expr Provides a correction for the rule, this field can be repeated to provides more than one choice. Only the first one will be used for `autofix' rules. `warning' and `error' do not provides fixes. The captured patterns can be used here with variables `$1', `$2', and so on. hint text Provides some explanations, this will be used as reviewer comments in review mode. Optional fields: name name Use this to give the rule a name. valid [name] Provides a validation test, it can be named or anonymous. For anonymous validation, the test definition must follow. This field can be repeated more than once, if any of the validation test succeed, the rule does not apply. valid A validation test starts at a `valid' statement, and stops at the first `end_valid' or at the beginning of a rule, a comment, a list or another validation test. Mandatory field: pre regex in regex> post regex Try the regex before, in or after the match of the regex rule. At least one of these test must be provided. If all tests are success- ful, the rule won't apply. Optional field: name name Use this to give the validation test a name. comment A comment starts at a `comment' statement, and stops at the first `end_comment' or at the beginning of a rule, a comment or a list. Comments are just skipped, no other rule and no spelling are performed on them. Mandatory field: skip regex A regex matching the text of the comment. Do not use `start' and `stop' with this. start regex stop regex Regexs defining the beginning and the end of the comment, all the text between will be considered as comment. Do not use `skip' with this. Optional fields: name name Use this to give the comment a name. start_offset stop_offset Defines where the comment really starts or end. Values are `s' for the place the match starts, `s+<n>' for n characters after the match starts, `e' for the place the match ends, or `e-<n>' for n characters before the match ends. Defaults are `s' for `start' matches and `e' for `stop' matches. SEE ALSO
acheck(1), acheck(5) AUTHOR
Nicolas Bertolissio <nico.bertol@free.fr> perl v5.8.4 2003-07-20 ACHECK-RULES.5(5)
All times are GMT -4. The time now is 04:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy