Sponsored Content
Top Forums Shell Programming and Scripting Deleting table cells in a script Post 302265195 by phpfreak on Friday 5th of December 2008 10:48:30 PM
Old 12-05-2008
Script doesn't err but the sed isn't clearing the cells. I found when I ran it manually on the file..


Code:
# cp status.html teststatus.html
# OUT=`cat teststatus.html` && echo $OUT |sed 's/<td>[a-zA-Z0-9|(|)]<\/td>//'
OUT=<?xml: Command not found.
# grep -n "<?xml" teststatus.html
1:<?xml version="1.0" encoding="iso-8859-1"?>
#

Within the script that brings the page into my box I added:

Code:
sed -e '1d' <status.html > ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3 ;
mv ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3 sentinalstatus.html

I go to test again and hence it complains about something else..

Code:
# OUT=`cat teststatus.html` && echo $OUT |sed 's/<td>[a-zA-Z0-9|(|)]<\/td>//'
OUT=<!DOCTYPE: Command not found.
#

I'm probably missing quotes somewhere I figure. Tried adding them to the var but it doesn't work. Below is an update of what I have so far.


Code:
#!/bin/sh

#TD=0
CT=0
cat status.html |while read LINE
do
    # Check to see if the LINE is non-empty, and has a <td> tag in it.
	TD=`echo $LINE |grep '</td>'`
	if [ -n "$TD" ] ; then
        # Increase the TD counter by 1
        CT=`echo "$CT+1" |bc`
        
        # Check to see if the TD counter is at 6 (we are at 7th TD as the counter starts at 0 not 1)
        if [ "$CT" -eq 7 ] ; then
            # Use sed to remove this TD tag AND everything in between
            echo $LINE |sed 's/<td>[a-zA-Z0-9|(|)]<\/td>//' >> ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3
        else 
            echo $LINE >> ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3
        fi
    else
        echo $LINE >> ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3
    fi
    
    # If we are leaving a table row the we need to reset the TD counter!
    TR=`echo $LINE |grep '</tr>'`
    if [ -n "$TR" ] ; then
                CT=0
    else
    	echo "" > /dev/null
	fi
	
    HTML=`echo $LINE |grep '</html>'`
    if [ -n "$HTML" ] ; then 
        mv ztmp.Ps23zp2s.2-Fpps3-wmmm0dss3 status.html
	else	
		echo "" > /dev/null
	fi

done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

rm -i and deleting files from an index table

Hi, I am trying to make a command to delete my files out the trash can, but one at a time. I am currently using rm - i to do this, but the original file locations for restoring my files are heard on a .txt file which I am using as an index table. How would I manage to make it so that if I... (21 Replies)
Discussion started by: E-WAN
21 Replies

2. UNIX for Dummies Questions & Answers

Deleting cells that contain a specific number only from a space delimited text file

I have this space delimited large text file with more than 1,000,000+ columns and about 100 rows. I want to delete all the cells that consist of just 2 (leave 2's that are not by themselves intact): File before modification aa bb cc 2 NA100 dd aa b1 c2 2 NA102 de File after modification... (1 Reply)
Discussion started by: evelibertine
1 Replies

3. UNIX for Dummies Questions & Answers

Filling empty cells

How do you fill empty cells that do not have any data in them with "X" in a tab delimited text file? Thanks! (4 Replies)
Discussion started by: evelibertine
4 Replies

4. Shell Programming and Scripting

Moving new row and deleting old row to another table

Hi, I want to move a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). I already use this script but doesn't work as I expected. CHECK_KEYWORD="$( mysql -uroot -p123456 smsd -N... (7 Replies)
Discussion started by: jazzyzha
7 Replies

5. Shell Programming and Scripting

In php, Moving a new row to another table and deleting old row

Hi, I already succeed moving a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). But it can't delete the old row. Please help me with the script. my php script: INSERT INTO... (2 Replies)
Discussion started by: jazzyzha
2 Replies

6. UNIX for Dummies Questions & Answers

Deleting unwanted text from a table

Hi everyone, I have a microbial diversity table in the format ;k__kingdom; p__phylum, etc, somer rows have descriptions before the :k__ (like the af028349.1 below) is there a way I can get rid of this text (which is different every time) and keep all the other columns? Thanks a bunch! ;... (1 Reply)
Discussion started by: Juan Gonzalez
1 Replies

7. Programming

Perl script to merge cells in column1 which has same strings, for all sheets in a excel workbook

Perl script to merge cells ---------- Post updated at 12:59 AM ---------- Previous update was at 12:54 AM ---------- I am using below code to read files from a dir and print to excel. open(my $in, '<', $file) or die "Could not open file: $!"; my $rowCount = 0; my $colCount = 0;... (11 Replies)
Discussion started by: Jack_Bruce
11 Replies

8. UNIX for Beginners Questions & Answers

BASH SCRIPT - Insert date into cells in cvs file

Hi, I'm looking to accomplish the following. Insert current date into three places/cells within a cvs, every time the bash script is executed. The cells are column A,B,C row 2. Row 1 is reserved for the headers. The file name is always orders.csv. These three cells we always have an old... (1 Reply)
Discussion started by: Rookievmc
1 Replies

9. UNIX for Beginners Questions & Answers

Merge cells in all rows of a HTML table dynamically.

Hello All, I have visited many pages in Unix.com and could find out one solution for merging the HTML cells in the 1st row. (Unable to post the complete URL as I should not as per website rules). But, however I try, I couldn't achieve this merging to happen for all other rows of HTML... (17 Replies)
Discussion started by: Mounika
17 Replies

10. UNIX for Beginners Questions & Answers

Remove duplicates in a dataframe (table) keeping all the different cells of just one of the columns

Hello all, I need to filter a dataframe composed of several columns of data to remove the duplicates according to one of the columns. I did it with pandas. In the main time, I need that the last column that contains all different data ( not redundant) is conserved in the output like this: A ... (5 Replies)
Discussion started by: pedro88
5 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 11:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy