Index

Subject : Re: LUG: Bash Help

From : Edward Anderson <nilbus@nilbus.[redacted]>

Date : Wed, 02 Mar 2011 13:51:54 -0500

Parent


you can't use a multi-character delimeter with cut. Also your loop is looping over only 1 line.


Try using sed instead of a bash script:

sed -e 's/Alt/\nAlt/g' /home/jamie/Downloads/LOG6.txt > /home/jamie/Downloads/new.txt

On Wed, Mar 2, 2011 at 1:45 PM, John Nance < jjnance@ncsu.[redacted] > wrote:
Hey LUG,

I've accidently recorded a long data file that's only one line. I'd
like to break this line into a manageable data file that has a new
line each time the string "Alt" is encountered in the original file.
This is what I've got so far based on googling, but it's still
returning a blank "new.txt" file. I've got very little experience
using bash. Ideas?

#!/bin/bash

while read myline; do
lin = "$(echo $myline | cut -dAlt)"
echo lin >> /home/jamie/Downloads/new.txt
done < /home/jamie/Downloads/LOG6.txt

exit

I'll be hanging out in the IRC #ncsulug for the next bit if anyone has
quick questions or responses.

Thanks,
Jamie Nance