- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: SED help
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
Discussions
Discussions
Forums
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
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
тАО05-07-2008 02:06 AM
тАО05-07-2008 02:06 AM
I want to remove a "." from the end of the path from a users profile and want to use sed.
I use this string to determine to determine the period "." in an if statement:
echo $PATH |awk -F":" '/\.$/ {print $NF}'
if true what is the best way to use sed to remove the ".":
my method:
if [[ $(echo $PATH |awk '/\./ {print NF}') -gt "0" ]] ; then
cp /home/
then I have difficulty replacing the . from the profile and recreate the .profile ....
can anyone please help?
thanks
Chris.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 02:16 AM
тАО05-07-2008 02:16 AM
Re: SED help
Why don't you use the form of the ls command to list just the file name.
ls -
So it shows up as
.profile
Then pipe that to tr and do a tr "." ""
I don't have access to a system today so I didnt' test the tr syntax.
Or if you want to just replace the . at the beginning of the
.profile
Pipe it to sed -e 's/^.//g'
that should work. May have to \ out the . though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 02:30 AM
тАО05-07-2008 02:30 AM
Re: SED help
I only echo the path of the user in this example however I will check the .profile of the user I need to change.
I cannot use
# sed 's/\.//' as this will remove any other "." from the profile so all I am intereted in is the ^PATH=* then recreate the file without the "." in the path.
thanks anyway.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 02:53 AM
тАО05-07-2008 02:53 AM
Re: SED help
Then my solution may work.
And put a ^ in the sed statement ^\. to indicate to find only the . at the beginning.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 03:13 AM
тАО05-07-2008 03:13 AM
Re: SED help
if [[ $(awk '/^PATH.+\.$/ {print NF}' /home/ca/.profile) -gt "0" ]] ; then
cp /home/ca/.profile /home/ca/.profile.bck
cat /home/ca/.profile.bck |sed -e '/^PATH/s/\.//' > /home/ca/.profile
fi
is this a logical method?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 03:30 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 03:47 AM
тАО05-07-2008 03:47 AM
Re: SED help
if I just run s/\.$//' then this will remove any "." from the profile.
I will take a look at the component method so thanks ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2008 03:48 AM
тАО05-07-2008 03:48 AM