- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Spliting and merging files
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
08-24-2005 02:51 AM
08-24-2005 02:51 AM
i have got a output of counters in the following format
Counter = 12
coun = 234
now i want to open the file in Microsoft excel, sheet the problem is excel sheet need a tab difference to recognize the difference between any two words otherwise it will think the whole as a single word.
and cut command is also failed to distinguish the counter and values as fields it is thinking it as a single filed.
how to proceed now?
There e are lot of counters like this and values will continuously increasing.
From my view i think easiest way is to cut the alphabets and numerical separately merging it with a tab space.
plz help my providing a solution
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:55 AM
08-24-2005 02:55 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:57 AM
08-24-2005 02:57 AM
Re: Spliting and merging files
Excel can import with any field separator, so you should be able to select "space" as a field separator.
For cut, you can use the option -d" " to set "space" as a delimiter.
Or you can use awk which by default will allow any whitespace (space, tab etc)
awk '{print $1,$3}' filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 02:58 AM
08-24-2005 02:58 AM
Re: Spliting and merging files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:00 AM
08-24-2005 03:00 AM
Re: Spliting and merging files
Let me understan better, the entire file is one colum with counter=number? correct? and also it has many lines with the same format the difference is that some are Couunter and some are count, correct?
if that is correct you can try the follwiing
cat
do
echo "$x \n" >> newfile
done
hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:01 AM
08-24-2005 03:01 AM
Re: Spliting and merging files
DATAFILE=/path/to/my/datafile
NEWFILE=/path/to/tab/delimited/file
COUNTERS_PER_LINE_in_EXCEL=15 # modify this as you wish
cell_ctr=0
cat $DATAFILE|while read a b c
do
printf $c"\t" >> $NEWFILE
(( cell_ctr=$cell_ctr+1 ))
if [ $cell_ctr -gt $COUNTERS_PER_LINE_in_EXCEL ]
then
printf "\n" >> $NEWFILE
cell_ctr=0
fi
done
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:04 AM
08-24-2005 03:04 AM
Re: Spliting and merging files
awk -F= '{print $1","$2}' filename > newfilename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:06 AM
08-24-2005 03:06 AM
Re: Spliting and merging files
Thanks for all u'r valuble response.
Pat you have simply slapped me.. with your command, it is excellent. but comma (,) did not work i don't know exactly the reson but insted of comma(,) i have inserted a tab space
:%s/=/ /g
and it done the magic. now even cut command is looking it as a seperate field with may help me when i have same counters from different machines to merge in the same file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:12 AM
08-24-2005 03:12 AM
Re: Spliting and merging files
i have two files
one
filed1 field2
counter 3
count 3
another file
filed1 field2
counter 6
count 7
now i want to do
file1 file1 file2
field1 filed2 field2
counter 3 6
count 3 7
note the counter and its values are not the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:27 AM
08-24-2005 03:27 AM
Re: Spliting and merging files
The default delimiter for cut is
# cut -d" "
In your case it shoud be:
# cut -d"=" -f
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:30 AM
08-24-2005 03:30 AM
Re: Spliting and merging files
paste file1 file2
output was like this
ffile1 file1
ifiled1 filed2
l
e
2
f
i
e
l
d
2
7counter 3
6count 3
paste file2 file1 (not happening)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2005 03:35 AM
08-24-2005 03:35 AM
Re: Spliting and merging files
to be clear on what we are taking i'm opening a new case.
thanks to all