HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- More script help?
Operating System - HP-UX
1834137
Members
2388
Online
110064
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 02:16 PM
12-11-2001 02:16 PM
We have a file in which we would like to parse out lines in which the first character is the letter s. I have written the script below which works, but I was wondering if there is a better/shorter way to do this.
cat $file |while read line
do
fstchar=`echo $line |cut -c1-1`
if [[ $fstchar = "s" ]];
then
echo "$line"
fi
done
Also, I noticed that if I didn't enclose the last echo variable in "'s, it would strip all white space. Why?
Thanks again,
Greg
cat $file |while read line
do
fstchar=`echo $line |cut -c1-1`
if [[ $fstchar = "s" ]];
then
echo "$line"
fi
done
Also, I noticed that if I didn't enclose the last echo variable in "'s, it would strip all white space. Why?
Thanks again,
Greg
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 02:19 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2001 02:24 PM
12-11-2001 02:24 PM
Re: More script help?
Hi Greg,
grep "^s" your_file
If there are no white spaces before the line this will not work. It will be complicated with sed's or the way you are doing.
-Sri
grep "^s" your_file
If there are no white spaces before the line this will not work. It will be complicated with sed's or the way you are doing.
-Sri
You may be disappointed if you fail, but you are doomed if you don't try
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP