The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find command takes a lot of time ( can I skip directories) knijjar Shell Programming and Scripting 3 08-12-2008 08:08 PM
Query regarding the functionality of OPTIONS (SKIP=1) thayaparani Shell Programming and Scripting 1 01-21-2008 09:54 PM
skip reading certain lines in a file paulsew UNIX for Dummies Questions & Answers 5 03-26-2007 03:07 AM
Skip new line pmpx Shell Programming and Scripting 2 10-13-2005 12:43 AM
FreeBSD skip UserConfig... Enoch Chan BSD 2 09-03-2003 05:48 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-16-2005
rwunwla rwunwla is offline
Registered User
  
 

Join Date: Dec 2005
Location: Jersey City, NJ
Posts: 9
Question Skip item by using substring

I have a file contents like this....

item1
item2
#item3
item4
#item5
item6
....

I have a KSH script to read this file into an array.
I have a for loop which will read each item...
I want to be able to skip those item start with # sign as first character in a if condiction inside the for loop.

How can I use substr, or parse or whatever way in ksh to detect the first character is a # sign.

Thanks in advance.
  #2 (permalink)  
Old 12-16-2005
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
Try this

grep -v "^#" file.dat | \
while read line
do
echo "Storing into array"
done
  #3 (permalink)  
Old 12-16-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
Code:
#!/bin/ksh

file='rw.txt'

while read line
do
   (( $(expr "${line}" : '^#') )) && continue;
   echo "line->[${line}]"
done < "${file}"
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 08:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0