- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell script 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
09-13-2004 12:28 AM
09-13-2004 12:28 AM
Shell script question
I need to create a new file within a shell script so that the new file may be then manipulated. I know the following :-
cat > filename but this hangs. Can anyone suggest another means so that filename may then be copied or moved ?
Thanks
Jeff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 12:32 AM
09-13-2004 12:32 AM
Re: Shell script question
LOG=/tmp/some.log
if [ -f $LOG ]
then
mv $LOG $LOG.old
fi
cat /dev/null > $LOG
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 12:34 AM
09-13-2004 12:34 AM
Re: Shell script question
touch file_name
echo "something" >> file
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 12:36 AM
09-13-2004 12:36 AM
Re: Shell script question
touch filename
touch
By simple you can create as,
> filename
or
cp /dev/null filename
More you can create, file as,
>| filename
Where,
>| used for when the file exists there. By default if you user > filename on
set -o noclobber
> filename
will make error messages for existing files.
So use
>| filename
to avoid error to update informations of file.
REgards
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 12:37 AM
09-13-2004 12:37 AM
Re: Shell script question
'touch filename' will create a file if it doesn't exist already.
Simply '> filename' will create a file and also empty it if it already exists.
If you know what data you want it to contain, you can use cat with a 'here' document as follows:
cat > filename << EOF
your
data
EOF
EOF is an arbitrary terminator, you can pretty much use whatever you like. See man sh-posix for full details.
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2004 12:41 AM
09-13-2004 12:41 AM
Re: Shell script question
It may be used as,
cat filename > newfilename
cat filename >| newfilename (noclobber mode)
or
cat filename >> newfilename
It will append content.
Else as,
echo "test" | cat - > filename
- --> collect all stdoutput message which got from pipe redirection.