Shell script to print date and no.of records


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to print date and no.of records
# 8  
Old 12-10-2012
go through the ABS (advanced bash scripting guide), you should get all the answers.

http://www.google.com.au/#q=advanced...pw.r_qf.&cad=b
This User Gave Thanks to rdcwayx For This Post:
# 9  
Old 12-10-2012
thank u very much for your time being help... Smilie
# 10  
Old 12-10-2012
Also in this forum, has "man page" already:

Man Page for printf (linux Section 1) - The UNIX and Linux Forums

Man Page for bash (linux Section 1) - The UNIX and Linux Forums
Code:
      ${parameter:offset}
       ${parameter:offset:length}
	      Substring Expansion.  Expands to	up  to	length	characters  of
	      parameter  starting  at  the  character specified by offset.  If
	      length is omitted, expands to the substring of parameter	start-
	      ing at the character specified by offset.  length and offset are
	      arithmetic expressions (see ARITHMETIC  EVALUATION  below).   If
	      offset  evaluates  to a number less than zero, the value is used
	      as an offset from the end of the value of parameter.  Arithmetic
	      expressions  starting  with  a - must be separated by whitespace
	      from the preceding : to be distinguished from  the  Use  Default
	      Values  expansion.   If  length  evaluates to a number less than
	      zero, and parameter is not @ and not an indexed  or  associative
	      array,  it is interpreted as an offset from the end of the value
	      of parameter rather than a number of characters, and the	expan-
	      sion is the characters between the two offsets.  If parameter is
	      @, the result is length positional parameters beginning at  off-
	      set.   If parameter is an indexed array name subscripted by @ or
	      *, the result is the length members of the array beginning  with
	      ${parameter[offset]}.   A  negative  offset is taken relative to
	      one greater than the maximum index of the specified array.  Sub-
	      string  expansion applied to an associative array produces unde-
	      fined results.  Note that a negative offset  must  be  separated
	      from  the  colon	by  at least one space to avoid being confused
	      with the :- expansion.  Substring indexing is zero-based	unless
	      the  positional  parameters are used, in which case the indexing
	      starts at 1 by default.  If offset  is  0,  and  the  positional
	      parameters are used, $0 is prefixed to the list.

# 11  
Old 12-10-2012
hi,
by the above code while trimming the length of the filename to 30 bytes ,the extension is also getting trimmed Smilie

like if the filename is abscderss.txt(assume as its length is greater than 30 bytes)

the code u above mentioned is printing the output as

abscder (it is removing extension too )


thanks in advance
saikumar
# 12  
Old 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 Smilie
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compare Date to today's date in shell script

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

2. Linux

How to calculate the quarter end date according to the current date in shell script?

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

3. Shell Programming and Scripting

Delete db records from shell script

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

4. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

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

5. Shell Programming and Scripting

Shell script matching similar records

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

6. Shell Programming and Scripting

Need help in Shell Script comparing todays date with Yesterday date from Sysdate

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

7. Shell Programming and Scripting

Help with shell script in formatting the records.

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

8. Shell Programming and Scripting

How to increment a user defined date value in the DATE format itself using shell script?

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

9. Shell Programming and Scripting

need shell script to read particular records from a file

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

10. UNIX for Dummies Questions & Answers

update records in a file using shell script...

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
Login or Register to Ask a Question