- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Shell Script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- 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
тАО07-19-2005 07:32 PM
тАО07-19-2005 07:32 PM
e.g.
cat file1 | while read line
do
???????
???????
done
thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 07:57 PM
тАО07-19-2005 07:57 PM
Re: Shell Script
way 1
touch newfile
cat file1 | while read line;
do
echo $line | grep 'string' >> newfile
done
way 2
(
while read line;
do
echo $line | grep 'string'
done < inputfile
) > newfile
way 3:
grep -E 'string1|string2|stringn' inputfile > newfile
hth.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 07:58 PM
тАО07-19-2005 07:58 PM
Re: Shell Script
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 08:40 PM
тАО07-19-2005 08:40 PM
Re: Shell Script
Basically I have file1 which contains an output of a sw depot. In file2 I have a list of software that I want to check is in file1... how do I do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 09:24 PM
тАО07-19-2005 09:24 PM
Re: Shell Script
I belive you would use the product number in the output from swlist to "grep" for the same product number in the second file.
I suggest using "join" for this task. join matches fields from two files and print out selected fields from both of the files. The files must be sorted , using the matching field as sort key.
For more details, see the man page for join.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 10:01 PM
тАО07-19-2005 10:01 PM
Re: Shell Script
file1 contains listing of software depot
file2 contains listing of software product numbers.
I want to, using a loop?, in one go, check the contents of the first file, file1, using file2 as a sort of input or grep. I know you can do this using a for/while loop, but what would be the right syntax???????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 10:32 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 10:58 PM
тАО07-19-2005 10:58 PM
Re: Shell Script
try using diff -f
Neil.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 11:00 PM
тАО07-19-2005 11:00 PM
Re: Shell Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2005 11:04 PM
тАО07-19-2005 11:04 PM
Re: Shell Script
by product number use the following
cat file2 | while read line;
do
## line is one field record product number ##
grep -q $line file1
if [ $? -eq 0 ]; then ## if found ##
echo "Product depot $line was fonund in the file1"
else ## if not found ###
tput smso ## reverse video ##
echo "Product $line is not in file1 ..."
tput rmso ## normal video ##
fi
done
I hope this example helps
done