Sponsored Content
Full Discussion: Better way to do this?
Top Forums Shell Programming and Scripting Better way to do this? Post 302405537 by hj007 on Friday 19th of March 2010 05:28:44 AM
Old 03-19-2010
Better way to do this?

Hi Experts,

After the great suggestions I received yesterday, i'm back again, asking for more Smilie.
I have close to 8-10 lines of code performing an operation, id like to know, if there is a more compact way to do this.

# Removes the first line which is a message
Code:
awk 'match($0,"The following message") == 0 {print $0}' results_Linux.out > tmp
mv tmp results_Linux.out

# Removes the empty lines in the file
Code:
cat results_Linux.out | awk '$0!~/^$/ {print $0}' > tmp
mv tmp results_Linux.out

# Removes the last part of each line and adds a URL to the end
Code:
sed -e 's|WAITING (Being queued on farm)|http://dte/dte30/faces/monitorPage/jobId=|' results_Linux.out > tmp
mv tmp results_Linux.out

# Adds the first word of each line to the end of the line as well
Code:
awk '{print $0$1}' results_Linux.out > tmp
mv tmp results_Linux.out

# Send a mail to the user
Code:
userID=`whoami`
datetime=`date`
cat results_Linux.out | mail -s "Linux Run Results for - [$userID] executed on - [$datetime]"  $EMAIL

 
compact(1)						      General Commands Manual							compact(1)

Name
       compact, uncompact, ccat - compress and uncompress files, and cat them

Syntax
       compact [name...]
       uncompact [name...]
       ccat [file...]

Description
       The  command compresses the named files using an adaptive Huffman code.	If no file names are given, the standard input is compacted to the
       standard output.  The command operates as an on-line algorithm.	Each time a byte is read, it is encoded immediately according to the  cur-
       rent  prefix  code.   This code is an optimal Huffman code for the set of frequencies seen so far.  It is unnecessary to prepend a decoding
       tree to the compressed file since the encoder and the decoder start in the same state and stay synchronized.  Furthermore, and can  operate
       as filters.  In particular,
	    ... | compact | uncompact | ...
       operates as a (very slow) no-op.

       When  an  argument file is given, it is compacted and the resulting file is placed in file.C; file is unlinked.	The first two bytes of the
       compacted file code the fact that the file is compacted.  This code is used to prohibit recompaction.

       The amount of compression to be expected depends on the type of file being compressed.  Typical values of compression are: Text (38%), Pas-
       cal Source (43%), C Source (36%) and Binary (19%).  These values are the percentages of file bytes reduced.

       The command restores the original file from a file compressed by If no file names are given, the standard input is uncompacted to the stan-
       dard output.

       The command cats the original file from a file compressed by without uncompressing the file.

       The command is present only for compatibility.  In general, the command runs faster and gives better compression.

Restrictions
       The last segment of the file name must contain fewer than thirteen characters to allow space for the appended '.C'.

Files
       compacted file created by compact, removed by uncompact

See Also
       compress(1)

																	compact(1)
All times are GMT -4. The time now is 07:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy