Index

Subject : Re: LUG: Bash Help

From : Benjamin Berry <bsberry@ncsu.[redacted]>

Date : Wed, 02 Mar 2011 14:09:17 -0500

Parent


I know that using regular expressions usually means that now you have two problems, but would sed be a better tool for this?

sed "s/Alt/\r/" < LOG6.txt > new.txt

Or something like that? (Untested: typed on my android phone...)

Ben Berry

On Mar 2, 2011 2:01 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