HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Problem to newline change
Operating System - Linux
1828361
Members
3977
Online
109976
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
10-11-2005 12:59 PM
10-11-2005 12:59 PM
Hi all,
I have a very frustrate problem.
My input file time.txt is:
mfg pts/tu Fri Sep 30 15:24
mfg pts/tu Fri Sep 30 15:24
mfg pts/tGb Mon Sep 26 09:01
And my script I wrote
LTIME=$(more /tmp/time.txt |uniq |awk '{print $4 " " $5 " " $6 ","}')
If I do this in script I get
LTIME = Sep 30 15:24,
Sep 26 09:01,
If I manually run in Unix prompt, I get
LTIME = Sep 30 15:24, Sep 26 09:01,
How can I get the script having the same output as it is in Unit prompt? (I don't want the newline)
I have a very frustrate problem.
My input file time.txt is:
mfg pts/tu Fri Sep 30 15:24
mfg pts/tu Fri Sep 30 15:24
mfg pts/tGb Mon Sep 26 09:01
And my script I wrote
LTIME=$(more /tmp/time.txt |uniq |awk '{print $4 " " $5 " " $6 ","}')
If I do this in script I get
LTIME = Sep 30 15:24,
Sep 26 09:01,
If I manually run in Unix prompt, I get
LTIME = Sep 30 15:24, Sep 26 09:01,
How can I get the script having the same output as it is in Unit prompt? (I don't want the newline)
Solved! Go to Solution.
- Tags:
- awk
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2005 01:48 PM
- Tags:
- printf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2005 02:57 AM
10-13-2005 02:57 AM
Re: Problem to newline change
John,
I'm not sure what you mean. When I type the LTIME command just as you have it written (only the data file name is changed) then echo $LTIME I get coma separated output on one line.
When I put it in a script and echo $LTIME from the script I get coma separated output on one line.
I get the same output printed either way.
On a side note though, more is an interactive program, you may get faster results from cat or in this case just
Uniq /tmp/time.txt | awk '{#stuff}'
However, if you want to make certain that there are no new lines in the output printf may be the way to go
Awk '{ printf "%s %s %s, ",$4,$5,$6 }'
The reason this will work and print will not is that print always puts a new line on the end of its string and with printf if you want a new line, you have to put it in manually. Otherwise it will keep stacking onto the same line.
Hope this helps some
H
I'm not sure what you mean. When I type the LTIME command just as you have it written (only the data file name is changed) then echo $LTIME I get coma separated output on one line.
When I put it in a script and echo $LTIME from the script I get coma separated output on one line.
I get the same output printed either way.
On a side note though, more is an interactive program, you may get faster results from cat or in this case just
Uniq /tmp/time.txt | awk '{#stuff}'
However, if you want to make certain that there are no new lines in the output printf may be the way to go
Awk '{ printf "%s %s %s, ",$4,$5,$6 }'
The reason this will work and print will not is that print always puts a new line on the end of its string and with printf if you want a new line, you have to put it in manually. Otherwise it will keep stacking onto the same line.
Hope this helps some
H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2005 11:21 AM
10-13-2005 11:21 AM
Re: Problem to newline change
I found the solution Thank you...
printf does work...
printf does work...
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
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP