Useless Cat usage


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Useless Cat usage
# 1  
Old 11-07-2012
Useless Cat usage

Code:
cat ~/text.xt | while read line

do
        echo ${line} | perl -pe 's/(\d+)/localtime($1)/e'
done

how can i efficiently re-code the above?

also, no matter how i run this, i'm not getting the current/correct date. the contents of the "text.xt" looks like this:

Code:
[1352265804] SERVICES ................. 
[1352265804] SERVICES .................

when i run the above code, i get:

Code:
Thu Jan  1 00:00:01 1970 SERVICES .................
Thu Jan  1 00:00:01 1970 SERVICES .................

which is obviously not accurate.

unix os: linux/sunos
bash
# 2  
Old 11-07-2012
Re: the subject:
Code:
while read line; do
  ...
done < file

This User Gave Thanks to Scott For This Post:
# 3  
Old 11-07-2012
Code:
perl -pe 's/(\d+)/localtime($1)/e' ~/text.xt


Last edited by elixir_sinari; 11-07-2012 at 09:24 AM..
This User Gave Thanks to elixir_sinari For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

Quest for the most useless command

I wrote by accident: cd . and even hit ENTER. Then I realized this is probably the most useless command that you can imagine. Yes, perhaps it could assert that there is still a working filesystem, but I am not sure about it. What do you think? Can you think of any more useless commands? :) (6 Replies)
Discussion started by: colemar
6 Replies

2. What is on Your Mind?

Fighting useless use of cat

Fighting UUOC cat filename|while read line; do ... with sed 's/cat *\(*\) *|/<\1/g' I found that while loops are converted to <filename while read line; do ... Syntax error! Why syntax error? It would perfectly make sense. Further, read the article how-would-you-like-your-loops-served-today... (5 Replies)
Discussion started by: MadeInGermany
5 Replies

3. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

4. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

5. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

6. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

7. UNIX for Dummies Questions & Answers

useless command

Hi, I came across with this line "set -x" in the beginning of a script, but i can't find one logic reason for this... should be something else after, i think.... anyone can help? tanx (2 Replies)
Discussion started by: cabresto
2 Replies
Login or Register to Ask a Question