Shell pipeline help for a n00b

I need to read input from a file, and make sure nothing prints after column 72.

basically, ignore input after character 72 until the next newline character.

Any help is appreciated. I have been searching forever!

column 72 or character 72?
Paste some sample input

Character 72

cut -c1-72 input_file

column 72 - delimiter tab assumed, if different use -d option

cut -f1-72 input_file

--ahamed

1 Like

character 72. Sorry. Here is the sample input file

^\Be sure that you count the NEW characters to find where column 72 is^_^_^_$
A 72-character limit means only half of some 2-character codes survive:^X$
Make sure you don't mangle square brackets ('[' and ']').$
consecutive tabs (3 of them)$
12345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 2345678$
a ab abc abcd abcde abcdef x$
Embedded carriage returns can do unexpected^M things. $
Embedded backspaces can do unexpected ^H^H^H^H^H^H^H^H^Hwild and crazy things.$
The next line contains a delete character.$
^?$
Only control characters occur between the curly brackets in the next line.$
{^A^B^C^D^E^F^G^]^^^N^O^V^Z^[}$
Delete, null, and non-ascii characters occur between the curly brackets below.$
{^?^@M-^AM-~}$

---------- Post updated at 09:57 PM ---------- Previous update was at 09:55 PM ----------

ok cool, so if I also need to display control characters with ^? notation, and display $ at the end of newlines is the following line sufficient? or am I missing something?

#! /bin/csh -f
cat -v -e | cut -c1-72 input_file

cut -c1-72 input_file | cat -v -E

Not sure if this can be done in a better way! (UUoC applies here?)
I am not sure if cut will interpret control characters... Try it out...

--ahamed

k. it worked... kinda

This file has data for P1. To 'see' the special characters, display it w$
cat -vet ~masc0000/data1$
^\Be sure that you count the NEW characters to find where column 72 is^_^_^_$
A 72-character limit means only half of some 2-character codes survive:^X$
Make sure you don't mangle square brackets ('[' and ']').$
consecutive tabs (3 of them)$
12345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 2$
a ab abc abcd abcde abcdef x$
Embedded carriage returns can do unexpected^M things. $
Embedded backspaces can do unexpected ^H^H^H^H^H^H^H^H^Hwild and crazy things.$
The next line contains a delete character.$
^?$
Only control characters occur between the curly brackets in the next lin$
{^A^B^C^D^E^F^G^]^^^N^O^V^Z^[}$
Delete, null, and non-ascii characters occur between the curly brackets $
{^?^@M-^AM-~}$

it displayed some of the control charagcters, but I dont think it handled the tabs. any ideas?

Handled tabs means?
Can you paste the output of the command?

--ahamed

This file has data for P1. To 'see' the special characters, display it w
cat -vet ~masc0000/data1$
^\Be sure that you count the NEW characters to find where column 72 is^_
A 72-character limit means only half of some 2-character codes survive:^
Make sure you don't mangle square brackets ('[' and ']').$
consecutive tabs (3 of them)$
12345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 2
a ab abc abcd abcde abcdef x$
Embedded carriage returns can do unexpected^M things. $
Embedded backspaces can do unexpected ^H^H^H^H^H^H^H^H^Hwild and crazy t
The next line contains a delete character.$
^?$
Only control characters occur between the curly brackets in the next lin
{^A^B^C^D^E^F^G^]^^^N^O^V^Z^[}$
Delete, null, and non-ascii characters occur between the curly brackets
{^?^@M-^AM-~}$

Where it says: consecutive tabs (3 of them)

it should read: consecutive tabes^I^I^I(3 of them)

You mean you want to display tabs as ^I?

--ahamed

Yea, I thought the cat -v would do that.

Use -T

man cat

--ahamed

Thank you!! Works perfectly You've been such a big help!