On Wed, October 15, 2008 10:48 am, Jerry Geis wrote:
> Hi all,
>
> 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.
>
> I am missing something easy but I am not seeing it.
>
> Jerry
>
> ---
> I tried the script below but did not work.
>
> rm output.txt
> cat test.txt |
> while read LINE
> do
> newline=`echo $LINE | cut -f 19-`
> echo $newline >> output.txt
> done
>
> test.txt is below
> 10-Oct-08 08:14 am 10
> 10-Oct-08 08:20 am 20
> 10-Oct-08 08:24 am 30
> 10-Oct-08 08:29 am 40
> 10-Oct-08 08:34 am 50
> 10-Oct-08 08:39 am 60
> 10-Oct-08 08:44 am 80
> 10-Oct-08 08:49 am 10
> 10-Oct-08 08:54 am 10
> 10-Oct-08 08:56 am 10
>
> _______________________________________________
> CentOS mailing list
> CentOS@centos.org
> http://lists.centos.org/mailman/listinfo/centos
>
Instead of using cut -f use cut -c19-
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
10-15-2008, 02:48 PM
Jerry Geis
script question
Hi all,
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.
I am missing something easy but I am not seeing it.
Jerry
---
I tried the script below but did not work.
rm output.txt
cat test.txt |
while read LINE
do
newline=`echo $LINE | cut -f 19-`
echo $newline >> output.txt
done
test.txt is below
10-Oct-08 08:14 am 10
10-Oct-08 08:20 am 20
10-Oct-08 08:24 am 30
10-Oct-08 08:29 am 40
10-Oct-08 08:34 am 50
10-Oct-08 08:39 am 60
10-Oct-08 08:44 am 80
10-Oct-08 08:49 am 10
10-Oct-08 08:54 am 10
10-Oct-08 08:56 am 10
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
10-15-2008, 02:50 PM
Tim Nelson
script question
Hello Jerry-
Simply change the line:
newline=`echo $LINE | cut -f 19-`
to this:
newline=`echo $LINE | cut -c 19-`
You want to cut based on 'c'haracters, not 'f'ields. :-)
Tim Nelson
Systems/Network Support
Rockbochs Inc.
(218)727-4332 x105
----- "Jerry Geis" <geisj@pagestation.com> wrote:
> Hi all,
>
> 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.
>
> I am missing something easy but I am not seeing it.
>
> Jerry
>
> ---
> I tried the script below but did not work.
>
> rm output.txt
> cat test.txt |
> while read LINE
> do
> newline=`echo $LINE | cut -f 19-`
> echo $newline >> output.txt
> done
>
> test.txt is below
> 10-Oct-08 08:14 am 10
> 10-Oct-08 08:20 am 20
> 10-Oct-08 08:24 am 30
> 10-Oct-08 08:29 am 40
> 10-Oct-08 08:34 am 50
> 10-Oct-08 08:39 am 60
> 10-Oct-08 08:44 am 80
> 10-Oct-08 08:49 am 10
> 10-Oct-08 08:54 am 10
> 10-Oct-08 08:56 am 10
>
> _______________________________________________
> CentOS mailing list
> CentOS@centos.org
> http://lists.centos.org/mailman/listinfo/centos
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
10-15-2008, 02:54 PM
Pintér Tibor
script question
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.
I am missing something easy but I am not seeing it.
Jerry
---
I tried the script below but did not work.
rm output.txt
cat test.txt |
while read LINE
do
newline=`echo $LINE | cut -f 19-`
echo $newline >> output.txt
done
test.txt is below 10-Oct-08 08:14 am 10
why not simply
cut -b10- foo > bar
t
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
10-15-2008, 02:59 PM
"Filipe Brandenburger"
script question
Hi,
On Wed, Oct 15, 2008 at 10:48, Jerry Geis <geisj@pagestation.com> 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
HTH,
Filipe
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
10-15-2008, 03:29 PM
Les Mikesell
script question
Filipe Brandenburger wrote:
Hi,
On Wed, Oct 15, 2008 at 10:48, Jerry Geis <geisj@pagestation.com> 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@gmail.com
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
10-15-2008, 04:04 PM
"nate"
script question
Jerry Geis wrote:
> Hi all,
>
> 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.
[..]
> test.txt is below
> 10-Oct-08 08:14 am 10
If this is the format of your data you could use awk to do the same
thing
cat filename | awk '{print $4}'
nate
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
06-11-2010, 02:04 PM
Jerry Geis
script question
Hi all,
in a script if I have:
VERSION="3.2.0"
I can do:
echo jj-$VERSION-jj
and get jj-3.2.0-jj
however if I do:
echo jj_$VERSION_jj
I get jj_
How do I get the $VERSION to work with the underscores like the dashes do.
Thanks,
Jerry
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
06-11-2010, 02:06 PM
Kwan Lowe
script question
On Fri, Jun 11, 2010 at 10:04 AM, Jerry Geis <geisj@pagestation.com> wrote:
Hi all,
in a script if I have:
VERSION="3.2.0"
I can do:
echo jj-$VERSION-jj
and get jj-3.2.0-jj
however if I do:
echo jj_$VERSION_jj
I get jj_
How do I get the $VERSION to work with the underscores like the dashes do.
You can use ${VERSION} to separate it.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
06-11-2010, 02:07 PM
"Christoph Neuhaus"
script question
> however if I do:
> echo jj_$VERSION_jj
> I get jj_
>
> How do I get the $VERSION to work with the underscores like the dashes
> do.
echo jj_${VERSION}_jj
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos