- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: 2 vi and 1 grep questions
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
07-28-2003 12:08 PM
07-28-2003 12:08 PM
First I need to delete some lines from the password file, but as I delete (or yank) them I want to output them to either the buffer or another file and make sure that everything I've removed is safely in another file for reference.
Secondly I need to do a global removal of the characters ./ that appear at the beginning of each line in a file.
Finally the grep question (or any other technique); I have a directory that I want to list all the files in that directory over a certain age. I can use the find command by itself, but I want to see the list with the same output as a normal ll command. I can't figure out how to grep the ll output to search for files over 180 days old.
Easy points for someone I'll bet!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 12:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 12:33 PM
07-28-2003 12:33 PM
Re: 2 vi and 1 grep questions
For your first question, I would just make a copy of your passwd file to something like passwd.save, edit the passwd file and delete the records, and then use 'diff' to pick up the changes. Something like this might work:
cp passwd passwd.save
vipw passwd
diff passwd passwd.save >passwd.diff
For the second question, here is one way to do it with sed:
sed 's/^\.\///' somefile
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 12:34 PM
07-28-2003 12:34 PM
Re: 2 vi and 1 grep questions
Make a backup copy of the password file before you edit. Then use vipw to do the edit. See the man page for vipw for more info.
For the remove, try:
:s-"^./"--g
The trick is to remember that the field delimeter for the substitute command can be any character not in the search or the replace strings.
HTH
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 12:44 PM
07-28-2003 12:44 PM
Re: 2 vi and 1 grep questions
1. Make your modifications (changes, deletions, etc. Then write your output file with a *different* name an quit without updating your original file. Now, 'diff' the original and the modified file.
2. %s/^\///
...will eliminate forward slash (/) characters at the beginning (only) of all lines.
3. find /tmp -xdev -type f -mtime +180 -exec ls -l {} \;|sort -k9|more
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 01:42 PM
07-28-2003 01:42 PM
Re: 2 vi and 1 grep questions
Both Renda's and James' find commands worked. Thank you.
The diff comparison is clever but I know there is a way to yank stuff and output it to another file either with an ending command or appending to a seperate file as you work. I've done it before but didn't write it down.
Oh, for a clearly written vi reference with lots of examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 02:21 PM
07-28-2003 02:21 PM
Re: 2 vi and 1 grep questions
http://www.math.fu-berlin.de/%7Eguckes/vi/index.php3
http://www.faqs.org/faqs/editor-faq/vi/
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 06:25 PM
07-28-2003 06:25 PM
Re: 2 vi and 1 grep questions
You can (at least) do this:
To write lines 10-17 (for instance) of the file you are editting to 'myfile' do:
:10,17w myfile
To append lines 10-17 of the file you are editting to 'myfile' do:
:10,17w >> myfile
To write (or append) the entire file you are editting, simply drop the (address,address) couple:
:w >> myfile #...appends to 'myfile'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 10:58 PM
07-28-2003 10:58 PM
Re: 2 vi and 1 grep questions
For 1st question, take a backup when u r changing the file.
For u r second question, open the file in vi and give the following in escape mode. Search for "./" in begining of line and replace with nothing.
:s/^\.\///g
I tried the above command. It worked.
For the grep question,
for example,
find . -name "*" | xargs ll
Thanks and Regards
VJ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2003 11:03 PM
07-28-2003 11:03 PM
Re: 2 vi and 1 grep questions
I am really sorry. I missed 3chars in search and replace command. I forgot to give line numbers.
Here is the right one.
:1,$s/^\.\//g
Regards
VJ.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2003 01:03 AM
07-29-2003 01:03 AM
Re: 2 vi and 1 grep questions
about your
'but I know there is a way to yank stuff and output it to another file either with an ending command or appending to a seperate file'
try these steps :
- vi file1
- "A n yy (i.e. buffering n lines in A buffer)
- :e file2 (i.e. open new file named 'file2')
- "A p
- then save and close the 'file2'.
Hih
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2003 01:25 AM
07-29-2003 01:25 AM
Re: 2 vi and 1 grep questions
bye
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2003 12:55 AM
07-30-2003 12:55 AM
Re: 2 vi and 1 grep questions
The easiest way to remove './' at the begining of files:
In vi type:
:1,$s#^./##
At the command line:
cat | sed 's#^./##' >