- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting question
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
Forums
Discussions
Discussions
Discussions
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
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
04-17-2002 05:22 AM
04-17-2002 05:22 AM
Is it possible to do something like this
input file :
EXPZ_84940
KJAD_02938
KJAD_02938
NJSK_77490
....
output file:
EXPZ_84940
KJAD_02938 KJAD_02938
NJSK_77490
....
so that all the matching ones are beside each other.
Thanks for your time and help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 05:26 AM
04-17-2002 05:26 AM
Re: Scripting question
Try
Cat file | sort > newfile
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 05:32 AM
04-17-2002 05:32 AM
Re: Scripting question
That will only sort the files I have the files sorted but I need it to place the duplicate entry next to each other in the same line, like in the output.
Thanks for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 05:34 AM
04-17-2002 05:34 AM
Re: Scripting question
uniq will do that for you:
uniq file > newfile
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 05:44 AM
04-17-2002 05:44 AM
Re: Scripting question
sorry i haven't read your question exactly.
Here my little awk script for your job:
awk 'BEGIN{p=""}{
if(p=="")
p=$1
else
{
printf p;
if(p==$1)
printf " ";
else
printf "\n";
p=$1;
}
}END{print $1}' file >newfile
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 05:59 AM
04-17-2002 05:59 AM
Re: Scripting question
Thanks for your help and efforts but I get this error ..may be I am doing some thing wrong.
$ awk -f spl.awk tpp.txt
syntax error The source line is 1.
The error context is
awk >>> ' <<<
awk: Quitting
The source line is 1.
$
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 06:00 AM
04-17-2002 06:00 AM
SolutionHere's a way to do so in a script:
while read line
do
echo "$line\c"
prev=$line
while read line
do
if [ $prev = $line ]
then
echo " $line\c"
else
echo "\n$line\c"
fi
prev=$line
done
done
echo >>otfile
This only works if the duplicated lines are consecutive in the file. You could sort the file first to ensure duplicates follow each other.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 06:11 AM
04-17-2002 06:11 AM
Re: Scripting question
I wish I could give you more then 10 points .. it works really great...
Thanks a Million
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 06:16 AM
04-17-2002 06:16 AM
Re: Scripting question
Darrell