Shell pipeline help for a n00b


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell pipeline help for a n00b
# 1  
Old 11-22-2011
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!
# 2  
Old 11-22-2011
column 72 or character 72?
Paste some sample input

Character 72
Code:
cut -c1-72 input_file

column 72 - delimiter tab assumed, if different use -d option
Code:
cut -f1-72 input_file

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 11-22-2011
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 ----------

Quote:
Originally Posted by ahamed101
column 72 or character 72?
Paste some sample input

Character 72
Code:
cut -c1-72 input_file

column 72 - delimiter tab assumed, if different use -d option
Code:
cut -f1-72 input_file

--ahamed

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
# 4  
Old 11-22-2011
Code:
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
# 5  
Old 11-22-2011
Quote:
Originally Posted by ahamed101
Code:
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?
# 6  
Old 11-22-2011
Handled tabs means?
Can you paste the output of the command?

--ahamed
# 7  
Old 11-22-2011
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)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

FTP EOF n00b Question

Hi folks, can you help me decipher this? I know that ftp will accept input from all commands until it encounters EOF again but I don't quite make sense of what the entirety of the script is really trying to achieve. Many thanks. ftp -n someserver << EOF | head -20 user username@server... (2 Replies)
Discussion started by: verargulla
2 Replies

2. Shell Programming and Scripting

Unix Shell basic loop massive n00b

hey guys I would really appreciate some help, i need to do a project for a job that requires minimal UNIX scripting and im REALLY stuck basically Im stuck at what i believe is something really simple but i just dont have a clue how to do it efficiently and properly and i REALLY appreciate some... (16 Replies)
Discussion started by: thurft
16 Replies

3. Shell Programming and Scripting

Shell Scripting n00b

Hey Guys! I was hoping for some help with a simple script I'm trying to use. I have the script set up to pull some simple information out of a database .txt file and sed it into a preexisting template for assignment cover letters. The problem seems to be someplace in the sed statement but I... (5 Replies)
Discussion started by: BFeicht
5 Replies

4. IP Networking

tcp n00b - can't ping router

please help! I have a sun blade with 2 x nics configured, both on different subnets. The eri0 interface (192.168.0.100) is connected to my router (192.168.0.1), but if i try to ping the router, it times out. any suggestions are welcome - i noticed the 2 mac addresses are the same, i've set... (7 Replies)
Discussion started by: badoshi
7 Replies

5. Shell Programming and Scripting

scripting n00b question, please help :)

Okay, so I'm a little familiar with C and Linux, but my shell scripting experience is limited to say the least. I know that you begin a shell script with this #!/bin/bash Basically, I've written a C program that's output writes to a shell script. What my problem is, is I would like this shell... (4 Replies)
Discussion started by: beatzz
4 Replies

6. Shell Programming and Scripting

Comments within a shell pipeline

I've got a very ugly pipeline for analyzing web server logs (but nevermind the application; I've come across this in other scripts as well). I want to nicely comment the steps in the pipeline, but I can't seem to do it. I know, for instance that in csh/sh/bash, a # begins a comment, and any... (2 Replies)
Discussion started by: otheus
2 Replies

7. UNIX for Dummies Questions & Answers

N00b In Need!

Howdy all, just joined the forums after finding them on a good ole' google search. very impressed from what i've seen so far! I'm pretty new to the world of Unix/Linux, have just had a change of job role and been thrown in at the deep end! I'm now working on an Oracle 9i database using HPUX... (1 Reply)
Discussion started by: davesimm
1 Replies

8. UNIX for Dummies Questions & Answers

N00b question on CPU % in top

I have a process in my TOP output that is consistantly at 97% usage. I have 16 CPUs on my box. So is the 97% the cumalative usage of all the CPUs or just one? (3 Replies)
Discussion started by: kskywr
3 Replies

9. UNIX for Dummies Questions & Answers

Absolute n00b questions about Unix / Linux

Hi All, I have absolutely no experince with either one, and would LOVE to start from somewhere! So please guide me to some web sites (beside these great forums of course!) that I can obtain n00b information. (Books, links, resources, etc.) What software OS? should I begin with? I have heard... (2 Replies)
Discussion started by: CodeHunter
2 Replies

10. UNIX for Dummies Questions & Answers

OpenBSD N00b: HELP ME!!! AGGGH!!

Note: This is not meant to start a flamewar. I am looking for serious answers to questions regarding OpenBSD. I'm coming to OpenBSD from an eight year background in Linux (specifically various versions of RedHat and now Fedora Core 3). I have some experience with Solaris 8 and HP-UX 11/11i. I... (1 Reply)
Discussion started by: deckard
1 Replies
Login or Register to Ask a Question