Index
Subject
: Re: LUG: Bash Help
From
: Stephen Roller <scroller@ncsu.[redacted]>
Date
: Wed, 02 Mar 2011 12:51:54 -0600
Parent
Try this:
perl -i -p -e "s/Alt/Alt\n/g" < ~/Downloads/LOG6.txt
I have "perl -i -p -e" aliased to plsed in my bashrc; doing this kinda
textual replacement is so much easier in perl.
Good luck,
Stephen
On Wed, Mar 2, 2011 at 12: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
>