Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Limit the number of characters in a bash output Post 302567139 by Light_ on Saturday 22nd of October 2011 12:44:41 PM
Old 10-22-2011
Limit the number of characters in a bash output

I have a script that outputs the weather on two lines.
If possibly I would like to set a character limit on them

Currently it outputs something like
Quote:
Today:
Morning fog then afternoon showers.
Tomorrow:
Rain at times.
but I would like to limit the lines so appends an ellipsis if nescessary:
Quote:
Today:
Morning fog then afternoon sh(...)
Tomorrow:
Rain at times.
This is the script
Code:
#! /bin/bash


curl -s --connect-timeout 30 "ftp://ftp2.bom.gov.au/anon/gen/fwo/IDA00003.html" | grep "Melbourne" | sed -e 's,&nbsp;,,g' -e 's/<\/TD>/\]/g' -e 's/<[^>]*>//g' | awk -F ']' '{print "Today:"}{print $4}{print "Tomorrow:" }{print    $7}'
exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Limit of no of characters PER LINE in a unix file

Hi , Whats the limit of characters PER LINE in a unix file , allowed for editing..sort , cut , sed , awk etc (5 Replies)
Discussion started by: mohapatra
5 Replies

2. AIX

Is the Length of User ID for AIX Limit to 8 Characters?

Hi, I'm using AIX version 5.3 currently. I'm trying to create a user id, e.g. andyleong, which the system prompted the length is too long. 1. I would like to know is that the length of user id is limited to maximum 8 characters for AIX. 2. Is it apply to all versions of AIX? If no... (2 Replies)
Discussion started by: meihua_t
2 Replies

3. UNIX for Dummies Questions & Answers

Number of long limit

Hi Hi! I'm currently using AIX 5.2 and would like to know where can i find to see that there's a restriction on the number of login times a user can have. Example, I want give a 2 login per user but some one to give 3 login and some one have to give unlit login time (without logging off the... (2 Replies)
Discussion started by: herath
2 Replies

4. Solaris

How to limit number of Commands

Is there a way that I can limit number of commands that one user can run during period of time. For example Max 10 commands per senconds.:) (3 Replies)
Discussion started by: winger0608
3 Replies

5. HP-UX

cron 80 characters limit

Hello everyone. I am trying to set up a monitor based on a "top" command statistic as follows: top -bc -n1 > output.txt I've put this command into a small script which is called by a cron... but there is something strange happening: the cron is limiting the output to output.txt to 80... (3 Replies)
Discussion started by: MartinF
3 Replies

6. Shell Programming and Scripting

Limit on Number of characters in a line - Vi editor

In the vi editor, there seems to be some limit on the number of characters could be allowed in single line. I tried a line with characters up to 1880. It worked. But when i tried with something of 5000 characters, it doesnt work. Any suggestions. Thanks in advance! (2 Replies)
Discussion started by: nram_krishna@ya
2 Replies

7. UNIX for Dummies Questions & Answers

Limit reoccurrance of characters in lines

Hey guys and gals, Working on a script to limit the reoccurrance of characters in a line. sed "/\(.\).*\1/d" -i file.txt sed "/\(.\).*\1.*\1/d" -i file.txt sed "/\(.\).*\1.*\1.*1/d" -i file.txt .. To limit character reoccurance with 1x, 2x, 3x etc. However I would like to be able to... (2 Replies)
Discussion started by: TAPE
2 Replies

8. UNIX for Dummies Questions & Answers

Limit Number of files

hi guys how can i limit number of files in a disk or partition ? or how can i make a limit to inode number for a disk or partition ? ext3 or ext4 file system (1 Reply)
Discussion started by: mhs
1 Replies

9. Shell Programming and Scripting

How to count number of characters of wc -l output?

I want count number of characters / find the length of the 'wc -l' output This is the command bash-3.2$ gzcat /home/sid/file1.dat |wc -l 830752 So final out I want is 6 i.e lenght of 830752 I tried with awk bash-3.2$ gzcat /home/sid/file1.dat |wc -l | awk '{print length ($0)... (3 Replies)
Discussion started by: sidnow
3 Replies

10. Shell Programming and Scripting

Limit the number of characters in bash output

Hi, I need some help with this: I'm making a script which does a couple of things with image files. The script is supposed to echo the number of each image it is processing like this: Processing image1.jpgThe problem is with images with very long filenames, so I want to know how to limit the... (5 Replies)
Discussion started by: Shadow_Reaper
5 Replies
DDATE(1)						     Emperor Norton Utilities							  DDATE(1)

NAME
ddate - converts Gregorian dates to Discordian dates SYNOPSIS
ddate [+format] [date] DESCRIPTION
ddate prints the date in Discordian date format. If called with no arguments, ddate will get the current system date, convert this to the Discordian date format and print this on the stan- dard output. Alternatively, a Gregorian date may be specified on the command line, in the form of a numerical day, month and year. If a format string is specified, the Discordian date will be printed in a format specified by the string. This mechanism works similarly to the format string mechanism of date(1), only almost completely differently. The fields are: %A Full name of the day of the week (i.e., Sweetmorn) %a Abbreviated name of the day of the week (i.e., SM) %B Full name of the season (i.e., Chaos) %b Abbreviated name of the season (i.e., Chs) %d Ordinal number of day in season (i.e., 23) %e Cardinal number of day in season (i.e., 23rd) %H Name of current Holyday, if any %N Magic code to prevent rest of format from being printed unless today is a Holyday. %n Newline %t Tab %X Number of days remaining until X-Day. (Not valid if the SubGenius options are not compiled in.) %{ %} Used to enclose the part of the string which is to be replaced with the words "St. Tib's Day" if the current day is St. Tib's Day. %. Try it and see. EXAMPLES
% ddate Sweetmorn, Bureaucracy 42, 3161 YOLD % ddate +'Today is %{%A, the %e of %B%}, %Y. %N%nCelebrate %H' Today is Sweetmorn, the 42nd of Bureaucracy, 3161. % ddate +"It's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 26 9 1995 It's Prickle-Prickle, the 50th of Bureaucracy, 3161. Celebrate Bureflux % ddate +"Today's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 29 2 1996 Today's St. Tib's Day, 3162. BUGS
ddate(1) will produce undefined behavior if asked to produce the date for St. Tib's day and its format string does not contain the St. Tib's Day delimiters %{ and %}. NOTE
After `X-Day' passed without incident, the Church of the SubGenius declared that it had got the year upside down - X-Day is actually in 8661 AD rather than 1998 AD. Thus, the True X-Day is Cfn 40, 9827. AUTHOR
Original program by Druel the Chaotic aka Jeremy Johnson (mpython@gnu.ai.mit.edu) Major rewrite by Lee H:. O:. Smith, KYTP, aka Andrew Bulhak (acb@dev.null.org) Five tons of flax. DISTRIBUTION POLICY
Public domain. All rites reversed. SEE ALSO
date(1), http://www.subgenius.com/ Malaclypse the Younger, Principia Discordia, Or How I Found Goddess And What I Did To Her When I Found Her AVAILABILITY
The ddate command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. 59 Bureaucracy 3161 DDATE(1)
All times are GMT -4. The time now is 10:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy