12-10-2012
Quote:
Originally Posted by
hemanthsaikumar
hi,
by the above code while trimming the length of the filename to 30 bytes ,the extension is also getting trimmed
HTML Code:
for file in *
do
COUNT=$(wc -l < $file)
DATE=$(date +%Y/%m/%d)
SUFFIX=${file##*.}
NAME=${file%.*}
file=${NAME:0:30}.$SUFFIX
#echo $file `date +%Y/%m/%d` $count
printf "%-30s %10s %5d\n " $file $DATE $COUNT
done
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I have a file with 6 columns. First 3 columns together make unique record. I have a variable ($v) which hold a value that is obtained by a caliculaion. I have to replace value in 5th columnn with the value of the variable ($v). The value $v is caliculated from col4 and col6 values.
... (2 Replies)
Discussion started by: new_learner
2 Replies
2. Shell Programming and Scripting
i am reading an i/p file input.txt as below and want to read all filenames as in highlighted in bold below and put them in a different file output.txt. can someone help me with a shell script to do this? thanks in advance
regards
brad
input.txt
---------
START
TYPE:OPT
INIT_SEQ:01... (8 Replies)
Discussion started by: bradc
8 Replies
3. Shell Programming and Scripting
I need to increment a date value through shell script.
Input value consist of start date and end date in DATE format of unix.
For eg.
I need increment a date value of 1/1/09 to 31/12/09 i.e for a whole yr.
The output must look like
1/1/09
2/2/09
.
.
.
31/1/09
.
.
1/2/09
.
28/2/09... (1 Reply)
Discussion started by: sunil087
1 Replies
4. Shell Programming and Scripting
I have a text file in the following format. can any one please help me in printing the output in userfriendly format mentioned below.
Input.
1) /ss/abc/1/w/s/domainname/abc1/logname/
########error###################
########error###################
########error###################... (2 Replies)
Discussion started by: vinny81
2 Replies
5. Shell Programming and Scripting
Hi,
I want to compare today's date(DDMMYYYY) with yesterday(DDMMYYYY) from system date,if (today month = yesterday month) then execute alter query else do nothing.
The above requirement i want in Shell script(KSH)...
Can any one please help me?
Double post, continued here. (0 Replies)
Discussion started by: kumarmsk1331
0 Replies
6. Shell Programming and Scripting
hello all,
I have requirement to identify similar records matching about 80% to 90%.I have to black list customers with multiple accounts.
The data is in the Oracle Database, but is there any way I can get the data into flat file and compare the strings and fetch similar matching records?
... (2 Replies)
Discussion started by: kashik786
2 Replies
7. Shell Programming and Scripting
hi all,
How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt
how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies
8. Shell Programming and Scripting
Hello Mates,
I would request your help in a shell script,
simply I need to delete some matching db table records (rows) to ones in a given file:
------------------------------
#!/bin/bash
SQL="delete from numberlist where msidn='';"
MYSQL_USER="<your-user>"... (4 Replies)
Discussion started by: EAGL€
4 Replies
9. Linux
Hi,
My question is how to calculate the quarter end date according to the current date in shell script? (2 Replies)
Discussion started by: Divya_1234
2 Replies
10. UNIX for Beginners Questions & Answers
Hi Community!
Following on from this code in another thread:
#!/bin/bash
file_string=`/bin/cat date.txt | /usr/bin/awk '{print $5,$4,$7,$6,$8}'`
file_date=`/bin/date -d "$file_string"`
file_epoch=`/bin/date -d "$file_string" +%s`
now_epoch=`/bin/date +%s`
if
then
#let... (2 Replies)
Discussion started by: Greenage
2 Replies
FGETSS(3) 1 FGETSS(3)
fgetss - Gets line from file pointer and strip HTML tags
SYNOPSIS
string fgetss (resource $handle, [int $length], [string $allowable_tags])
DESCRIPTION
Identical to fgets(3), except that fgetss(3) attempts to strip any NUL bytes, HTML and PHP tags from the text it reads.
PARAMETERS
o $handle
-The file pointer must be valid, and must point to a file successfully opened by fopen(3) or fsockopen(3) (and not yet closed by
fclose(3)).
o $length
- Length of the data to be retrieved.
o $allowable_tags
- You can use the optional third parameter to specify tags which should not be stripped.
RETURN VALUES
Returns a string of up to $length - 1 bytes read from the file pointed to by $handle, with all HTML and PHP code stripped.
If an error occurs, returns FALSE.
Example #1
Reading a PHP file line-by-line
<?php
$str = <<<EOD
<html><body>
<p>Welcome! Today is the <?php echo(date('jS')); ?> of <?= date('F'); ?>.</p>
</body></html>
Text outside of the HTML block.
EOD;
file_put_contents('sample.php', $str);
$handle = @fopen("sample.php", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgetss($handle, 4096);
echo $buffer;
}
fclose($handle);
}
?>
The above example will output something similar to:
Welcome! Today is the of .
Text outside of the HTML block.
NOTES
Note
If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the
auto_detect_line_endings run-time configuration option may help resolve the problem.
SEE ALSO
fgets(3), fopen(3), popen(3), fsockopen(3), strip_tags(3).
PHP Documentation Group FGETSS(3)