Re: script question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Filipe Brandenburger wrote:
Hi,

On Wed, Oct 15, 2008 at 10:48, Jerry Geis <geisj@xxxxxxxxxxxxxxx> wrote:
I am trying to create a script that takes an entire file,
drops the first 19 characters from each line and creates a new file.
      newline=`echo $LINE | cut -f 19-`

What you want is "cut -c 19-" (-c as in characters) and not "cut -f
19-" (-f as in fields).

      echo $newline >> output.txt

This will also remove the spacing. You should at least use echo
"$newline" >>output.txt, but in any case it's silly as you can just:

cut -c 19- <test.txt >output.txt

Or sed -e 's/^...................//' <text.txt >output.txt
which might be a nicer starting point if you want to make other changes although it won't change a line with less than 19 characters. If you'd want that, 's/^.\{1,19\}//' should do it.

--
  Les Mikesell
   lesmikesell@xxxxxxxxx
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux