LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-12-2024, 02:25 AM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,639

Rep: Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525Reputation: 7525

instead of that for loop you can use sed again, like this:
Code:
cmd=$(printf "%s" "$dots" | sed 's![.]/!../!g')
cd "$cmd"
Putting all together you will get something like this:
Code:
_walk() {
    cmd=$(printf "%s/" "$1" | sed 's![^./]!!g;s!//*!/!g;s!\./!!g;s![.]!../!g')
    cd "$cmd"
}
It is definitely faster, simpler and posix compliant.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Walking" icons in KDE eddiep Mandriva 4 05-11-2006 01:18 PM
LXer: Kevin Carmony: Walking The Line of a Divided Community LXer Syndicated Linux News 1 05-09-2006 01:19 PM
SUSE 10 CD1 Boot Screen shows Walking Penguins, WTF AvatarofVirgo SUSE / openSUSE 3 11-10-2005 05:37 PM
KDE Panel moves to center of screen after walking away for 10 mins... Whitehat Linux - General 2 04-30-2003 07:24 PM
Walking a newbie through installing Linux hux Linux - General 2 01-18-2003 12:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration