From owner-freebsd-questions@FreeBSD.ORG Thu Jun 21 13:41:13 2012 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 575E61065674 for ; Thu, 21 Jun 2012 13:41:13 +0000 (UTC) (envelope-from odhiambo@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id CDF4F8FC25 for ; Thu, 21 Jun 2012 13:41:12 +0000 (UTC) Received: by werg1 with SMTP id g1so629304wer.13 for ; Thu, 21 Jun 2012 06:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=b5OcUmj+2ObYi3Lj/Bad2cfnrh+dPrGDuiacGejDXiY=; b=LqEzpU+DN5+6bS2s6eaRekS4W9o9ZPToAIZAi//LE1c7RkpKNFfx5hpmt9Y6AUBq9L 68XtBxlaggImMsQOicZdRKPrq907cRiR0uHJJKtHMIh8CM2EPptMut+zVId6OfK3/foY ZCjqxEgTpMSig8CGd72uONI7A1xSPb8AcCQztOfM8A/Q5wWbUmiULc3TrmeE1XU5uTZo eeDEE7skoEytat+8Twf45a5b2WawIGa5fjqPlRxqXXQDNiITuExAcYhJnWa4PWFBLOdj RB4JlE6IeBsU4AMEZh8+v9CLkTYOvskd3gUF2du0YbBVZTwRc0ChRE72TWaPzVNSrH3k uoww== Received: by 10.180.106.137 with SMTP id gu9mr20437318wib.20.1340286071725; Thu, 21 Jun 2012 06:41:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.75.151 with HTTP; Thu, 21 Jun 2012 06:40:31 -0700 (PDT) In-Reply-To: References: From: Odhiambo Washington Date: Thu, 21 Jun 2012 16:40:31 +0300 Message-ID: To: questions Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: A bash scripting question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2012 13:41:13 -0000 How Can I simplify/perfect the following script, so that I read _ALL_ the lines in the file and act on the content as shown below, so that I do not have to specifiy an action per line? This below is doing exactly what i need BUT reading one line at a time untill the 10th line, if i want more i add manually... This might help some1 someday! But if there is a way to perfect it please do so..... #!/usr/local/bin/bash smsfile=email_to_sms `grep Subject /var/spool/mail/sms >>$smsfile` if [[ -s $smsfile ]] ; then cat /dev/null > /var/spool/mail/sms sed -i 's/Subject: //g' $smsfile echo `sed -n '1p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==1 {print $1}' $smsfile` echo `sed -n '2p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==2 {print $1}' $smsfile` echo `sed -n '3p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==3 {print $1}' $smsfile` echo `sed -n '4p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==4 {print $1}' $smsfile` echo `sed -n '5p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==5 {print $1}' $smsfile` echo `sed -n '6p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==6 {print $1}' $smsfile` echo `sed -n '7p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==7 {print $1}' $smsfile` echo `sed -n '8p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==8 {print $1}' $smsfile` echo `sed -n '9p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==9 {print $1}' $smsfile` echo `sed -n '10p' $smsfile` | /usr/bin/gammu --sendsms TEXT `awk 'NR==10 {print $1}' $smsfile` else echo "***********Sorry the SMS FILE "$smsfile" is empty.************" fi gammu-smsd start cat email_to_sms >> email_to_sms2 cat /dev/null > email_to_sms -- Best regards, Odhiambo WASHINGTON, Nairobi,KE +254733744121/+254722743223 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ I can't hear you -- I'm using the scrambler.