- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How do I store command output/extract file content...
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
11-17-2009 04:33 AM
11-17-2009 04:33 AM
How can I do this?
Hrm, I was just thinking about it, maybe this would work:
command > filename
Then, later on, I want to extract the contents of the nth line within that 'filename', and use it somewhere else.
how could I do that?
Thanks.
Solved! Go to Solution.
- Tags:
- command substitution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2009 04:39 AM
11-17-2009 04:39 AM
Re: How do I store command output/extract file contents?
>>>command > filename
yes..this will work.
To get 9th line, you can use sed:
#cat
Regds..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2009 04:39 AM
11-17-2009 04:39 AM
Re: How do I store command output/extract file contents?
command |tee filename | head -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2009 04:47 AM
11-17-2009 04:47 AM
Re: How do I store command output/extract file contents?
I need to store the value in that line somehow, so that it can be inserted later.
I guess it helps if I go into a bit more detail.
i have a command, encrypt6.1, which generates encrypted passwords
it looks like this
hostname:/dir1/dir2 >encrypt6.1 password
ldfadslfie.1#!l1
hostname:/dir1/dir2 >
I was thinking I could do this:
hostname:/dir1/dir2 >encrypt6.1 password > pwordfile
I then later on, want to use what is inside that file, and I don't know how to do that.
basically, if I could figure out how to get the contents of the pword file, it would be called %encrypted%.
What I then want to do is this
hostname:/dir1/dir2/dir3 >string1:string2:%encrypted%:string3 >> pwordfile
So, if you can follow my pseudocode, I want to do this:
(1) Generate an encrypted password, and store it as the variable %encrypted% (not sure of how to do this)
(2) Later on, use this variable, by appending to a file.
I'm not sure how to do the variable part, but maybe now that I have explained a bit more, you can explain to me better how to achieve the result that I want?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2009 04:50 AM
11-17-2009 04:50 AM
Re: How do I store command output/extract file contents?
There should not be two "pwordfile" in the explanation above.
Replace one of the two with someone else.
I am unable to edit the post.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2009 05:11 AM
11-17-2009 05:11 AM
Solution> So, if you can follow my pseudocode, I want to do this:
(1) Generate an encrypted password, and store it as the variable %encrypted% (not sure of how to do this)
(2) Later on, use this variable, by appending to a file.
Shell variables are composed of letters, digits, or underscores. A letter or underscore must be the starting character. Hence, you could store the result of a command like this:
# DATE_VAL=$(date)
...and append this variable's value to a file thusly:
# echo ${DATE_VAL} >> myfile
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2009 07:57 AM
11-17-2009 07:57 AM
Re: How do I store command output/extract file contents?
Thanks. I'm glad that you were able to figure out what I was asking for, better than I could explain it.
So, in my case, I could do this:
# encrypt_string=$(encrypt6.1 password)
# echo string1:string2:${encrypt_string}:string3 >> usersfile
Thanks, you fully understood what I needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2009 08:00 AM
11-17-2009 08:00 AM
Re: How do I store command output/extract file contents?
Others provided help with extracting data from the nth line of a file, which can come in handy later.
Thanks all!