- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Update 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
08-19-2004 06:01 PM
08-19-2004 06:01 PM
# vi abc.txt
..abc....
.abc.....
...abc..
....abc.
"
"
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:20 PM
08-19-2004 06:20 PM
Re: Update content
I have one more requirement , if I want to update all files under a directory ( not only abc.txt , eg , all file under /home ) , what can I do ? thx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:31 PM
08-19-2004 06:31 PM
Re: Update content
ex.
cd /home
for f in `ls`
do
mv $f $f.tmp
sed -e 's/def/def/g' $f.tmp > $f
rm $f.tmp
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:37 PM
08-19-2004 06:37 PM
Re: Update content
vi file
Press Esc
:1,$ s/abc/def/g
:wq!
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:37 PM
08-19-2004 06:37 PM
Re: Update content
more correct version :)
cd put_dir
for f in `ls`
do
if [ -d $f ]
then
echo "$f -> directory"
else
mv $f $f.tmp
sed -e 's/def/def/g' $f.tmp > $f
rm $f.tmp
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:42 PM
08-19-2004 06:42 PM
Re: Update content
your method seems too complicate for me , can I use "find" to do it ? thx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:54 PM
08-19-2004 06:54 PM
Re: Update content
#!/bin/sh
count=1
for files in `ls -1 *.txt`
do
count=`expr $count + 1`
echo $count
sed -e 's/abc/def/g' $files > abc_new${count}.txt
done
-Brian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 06:58 PM
08-19-2004 06:58 PM
Re: Update content
perl -pi.orig -e 's,abc,def,g' *.txt
Original files will be saved with .orig suffix.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 07:59 PM
08-19-2004 07:59 PM
Re: Update content
As my above post , if I want to update all files under a directory ( , eg , all files under the directory /home , not only abc.txt ) , what can I do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 08:14 PM
08-19-2004 08:14 PM
Re: Update content
cd /home
mkdir /home/temp
#!/bin/sh
count=1
for files in `ls`
do
count=`expr $count + 1`
echo $count
sed -e 's/abc/def/g' $files > temp/$files
done
Then move the file from temp back to /home.
sks