Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Exclude lines which have blanks at certain positions Post 302248651 by helper on Sunday 19th of October 2008 01:31:03 AM
Old 10-19-2008
Here goes the input file :
Name of the file is test
000000000XXXXXXX XXXXXXXX NOTIXABCDHH450
000000000XXXXXXX XXXXXXXX NOTIXABCDHH450
000000000YYYYYY YYYYY NOTIXPQRSPULSAR
000000000YYYYYY YYYYY NOTIXPQRSPULSAR
000000000ZZZZZ ZZZZZZZ NOTIXABCDHH450
000000000ZZZZZ ZZZZZZZ NOTIXABCDHH450
000000000PPPPPPP PPPPPPP PAGI5 0000
000000000PPPPPPP PPPPPPP PAGI5 0000
000000000ZALKIM FERER NOTIXABCDZM371
000000000ZALKIM FERER NOTIXABCDZM371


I run this command

cat test | sort -y -t /tmp/usespace +0.55 -0.59

Here is the output of it
000000000PPPPPPP PPPPPPP PAGI5 0000
000000000PPPPPPP PPPPPPP PAGI5 0000
000000000XXXXXXX XXXXXXXX NOTIXABCDHH450
000000000XXXXXXX XXXXXXXX NOTIXABCDHH450
000000000ZZZZZ ZZZZZZZ NOTIXABCDHH450
000000000ZZZZZ ZZZZZZZ NOTIXABCDHH450
000000000ZALKIM FERER NOTIXABCDZM371
000000000ZALKIM FERER NOTIXABCDZM371
000000000YYYYYY YYYYY NOTIXPQRSPULSAR
000000000YYYYYY YYYYY NOTIXPQRSPULSAR

Now the first 2 lines have 4 spaces between PAGI5 and 0000.
Similary there may be so many lines which have blanks from position 55 to 59. I want to exclude all those lines on a fly and write others to another file.

I want to exclude all lines that have spaces at those positions meaning starting at 55 and ending at 59

Let me know regarding the same.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk modifying entries on 2 lines at 2 positions

Hi this script adds text in the correct place on one line only, in a script. awk 'BEGIN{ printf "Enter residue and chain information: " getline var < "-" split(var,a) } /-s rec:/{$7=a; } {print}' FLXDOCK but I need the same info added at position 7 on line 34 and... (1 Reply)
Discussion started by: gav2251
1 Replies

2. Shell Programming and Scripting

exclude lines in a loop

I use while do - done loop in my shell script. It is working as per my expectations. But I do not want to process all the lines. I am finding it difficult to exclude certain lines. 1) I do not want to process blank lines as well as lines those start with a space " " 2) I do not want to... (2 Replies)
Discussion started by: shantanuo
2 Replies

3. Shell Programming and Scripting

regular expression grepping lines with VARIOUS number of blanks

Hi, I need a regular expression grepping all lines starting with '*' followed by a VARIOUS number of blanks and then followed by the string 'Runjob=1'. I tried that code, but it doesn't work: grep -i '*'+'Runjob=1' INPUT_FILE >>OUTPUT_FILE Can someone help me? Thanks (8 Replies)
Discussion started by: ABE2202
8 Replies

4. Shell Programming and Scripting

awk script replace positions if certain positions equal prescribed value

I am attempting to replace positions 44-46 with YYY if positions 48-50 = XXX. awk -F "" '{if (substr($0,48,3)=="XXX") $44="YYY"}1' OFS="" $filename > $tempfile But this is not working, 44-46 is still spaces in my tempfile instead of YYY. Any suggestions would be greatly appreciated. (9 Replies)
Discussion started by: halplessProblem
9 Replies

5. Shell Programming and Scripting

File lines starts with # not processed or exclude that lines

I have requirement in my every files starting lines have # needs to be not processing or exclude the that lines. I have written a code like below, but now working as expected getting ERROR" line 60: 1 #!/bin/sh 2 echo ======= LogManageri start ========== 3 4 #This directory is... (1 Reply)
Discussion started by: Chenchireddy
1 Replies

6. Shell Programming and Scripting

File lines starts with # not processed or exclude that lines from processing

I have a file like below #Fields section bald 1234 2345 456 222 abcs dddd dddd ssss mmmm mmm mmm i need do not process a files stating with # I was written code below while read -r line do if then echo ${line} >> elif then ... (3 Replies)
Discussion started by: Chenchireddy
3 Replies

7. Shell Programming and Scripting

Filter lines based on values at specific positions

hi. I have a Fixed Length text file as input where the character positions 4-5(two character positions starting from 4th position) indicates the LOB indicator. The file structure is something like below: 10126Apple DrinkOmaha 10231Milkshake New Jersey 103 Billabong Illinois ... (6 Replies)
Discussion started by: kumarjt
6 Replies

8. Shell Programming and Scripting

Exclude multiple lines using grep

Hi, I'm working on a shell script that reports service status on a database server. There are some services that are in disabled status that the script should ignore and only check the services that are in Enabled status. I output the service configuration to a file and use that information to... (5 Replies)
Discussion started by: senthil3d
5 Replies

9. Shell Programming and Scripting

Replacing certain positions in lines with spaces

Hello, I have a file with hundreds of lines. Now I need to replace positions 750-766 in each line (whatever there is there) with spaces... how can I do that? Which command to use? The result will be all the lines in the file will have spaces in positions 750-766. Thanks! (3 Replies)
Discussion started by: netrom
3 Replies
EXPAND(1)						    BSD General Commands Manual 						 EXPAND(1)

NAME
expand, unexpand -- expand tabs to spaces, and vice versa SYNOPSIS
expand [-t tab1,tab2,...,tabn] [file ...] unexpand [-a] [-t tab1,tab2,...,tabn] [file ...] DESCRIPTION
The expand utility processes the named files or the standard input writing the standard output with tabs changed into blanks. Backspace characters are preserved into the output and decrement the column count for tab calculations. The expand utility is useful for pre-process- ing character files (before sorting, looking at specific columns, etc.) that contain tabs. The unexpand utility puts tabs back into the data from the standard input or the named files and writes the result on the standard output. The following options are available: -a (unexpand only) By default, only leading blanks and tabs are reconverted to maximal strings of tabs. If the -a option is given, then tabs are inserted whenever they would compress the resultant file by replacing two or more characters. -t tab1,tab2,...,tabn Set tab stops at column positions tab1, tab2, ..., tabn. If only a single number is given, tab stops are set that number of column positions apart instead of the default number of 8. ENVIRONMENT
The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of expand and unexpand as described in environ(7). DIAGNOSTICS
The expand and unexpand utilities exit 0 on success, and >0 if an error occurs. STANDARDS
The expand and unexpand utilities conform to IEEE Std 1003.1-2001 (``POSIX.1''). HISTORY
The expand command appeared in 3.0BSD. BSD
April 21, 2002 BSD
All times are GMT -4. The time now is 02:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy