Programming :: Go: A Cd/pushd/popd/dirs Replacement?
May 17, 2011
I have to use the older ksh on SUN and AIX alot...and kinda missed the pushd concept for jumping around a bunch of directories.but not really, because I didnt always want to pop off my directory, just wanted to cd there.So I wrote a ksh or bash friendly script with usage as below.Make it available by sourcing: . godir.sh
Code:
# Script: godir
# Written: 05-16-11 13:49:17 By: AWJurgensen
[code]....
View 1 Replies
ADVERTISEMENT
Jul 3, 2010
I really like pushd and popd, but I don't like their long spellings, so I made aliases: 'x' runs pushd and 'xx' runs popd. That's not bad, but I wish I could improve them in the following way:
x => If followed by a path, 'pushd' (and cd to) that path. If not given any arguments, run 'popd'.
xx => 'cd -'
The problem is implementing that pushd/popd in one command trick. Since tcsh does not have functions, I've been struggling hard to come with a solution. I made a script, and it works, but it only works within the context of the script. The script exits and not only am I still sitting in the same directory, but also my dirstack is emptied.
A similar problem: make 'cdd'. I remember using that program in DOS a long time ago. I would run 'cdd /path/to/directory' and cd to that path if it existed, or create it and cd to it if it didn't exist. Again, I made a script, but that only works within the context of the script, not my current shell. So the new dir is created, but my shell won't cd into it.
View 1 Replies
View Related
Aug 27, 2010
I need to list a directory recursively but I want to skip subdirs that were already mounted. There are 2 cases:
a) a filesystem was mounted twice, like in this example:
- "/dev/sda2" was mounted on "/mnt/mnt_point1"
- "/dev/sda2" was mounted on "/mnt/mnt_point2"
I want to list "/mnt" but descend only in "/mnt/mnt_point1"
b) part of the file hierarchy was remounted somewhere else, with "mount --bind":
- "mount --bind /home/user/tmp/test /home/user/tmp/mounted_test"
I want to list "/home/user/tmp" but descend only in "test" "statfs" and "statvfs" don't offer any information to discern if a dir was mounted twice. One solution would be to read "/etc/mtab" (as "find" command does it) and perform some checks, but I think that this is pretty expensive (one has to read /etc/mtab every time one encounters a dir; if this file is read only when program starts, a mount could occur in between reads, so that the program will be inaccurate). Another solution would be to filter kernel events (via libudev or Netlink) and do this reading of /etc/mtab only when a MOUNT event was issued.
View 1 Replies
View Related
Jan 9, 2011
My simple bash-script replaces --> by the HTML-entity for the right arrow. To be precise, it replaces --*> by → Until now, I used sed, for example:
Code: $ flight='AMS --> JFK'
$ echo "$flight" | sed -e 's/ --*> / → /g'
AMS → JFK With sed, -* matches zero or more dashes, because for sed the * is the Kleene Star matching zero or more instances of the previous element. So with sed, --*> matches exactly what I want:
Code:
->
-->
--->
---->
Because sed seems oversized for that task, I played around to accomplish the same with on-board means of bash without using sed. On first thought, this line looks like doing the same but it isn't:
Code: $ flight='AMS --> JFK'
$ echo "${flight// --*> / → }"
AMS → JFK As I recently learnt in this forum, this * isn't the Kleene Star. It is a multi-character wildcard matching any zero or more consecutive characters. So here, --*> matches:
Code:
->
-->
--->
---->
-<>
->>
-abc> And if you continue your flight to SEA, then the result is totally wrong because the * matches greedily:
Code: $ flight='AMS --> JFK --> SEA' $ echo "${flight// --*> / → }" AMS → SEA
The sed line above would produce the correct result and would match the dashes correctly.
View 3 Replies
View Related
Feb 19, 2011
I want to write Bourne-shell script that will be to do finding and replacement in any web page code (.htm file) name of the tied folder in which have been saved pictures, .css, .js and other files. This folder create a web browser when we save web page completely and has so name as web page and has ending '_files'. I have many web pages where name of their folder are incorrect. Of course, my web browser shows these web pages without pictures. I can count amount of web pages in a folder (/path) needed for me.
1) find /path -type f -name "*.htm*" -print | grep -c .htm or find /path -type f -name *.htm | wc -l I can get list of web pages.
2) ls /path *.htm > out-list But I don't know how to assign the value from out-list (2) or result commands from pipeline (1) to a variable. Then I want to do next:
3)
var="1"
# where variable 'list' is an amount of web pages
while [ $var -le $list ]
[code]....
4)assign the 1st (then 2nd , etc. ) value from out-list (2) to variable 'webfile'
sed -n $var,+0p out-spisok
5)find the 1st string value '_files' in the 'webfile' grep -m1 _files $webfile
6)For example, 'abracadabra_files' is an incorrect folder in the 'webfile' I must to know start and end position 'abracadabra' without ending '_files', "cut" name of the incorrect folder and assign it to the variable 'finder' finder = 'abracadabra' BTW, name of a folder before '_files' is between '="' and '_files' in any web page code.
7)foldernew = $webfile (without '.htm')' foldernew' is equal with name of the tied folder without ending '_files' in the folder '/path'
8)find and replace in the 'webfile' and save result in the 'webfile-out'sed s/$finder/$foldernew/g $webfile > $webfile-out
View 5 Replies
View Related
Sep 2, 2010
If say, I want to read the input given by user at the command prompt and write a code to execute the cmd given then which commands do i use to implement this ( Im writing the code in C )?
View 8 Replies
View Related
Jul 30, 2011
I'm trying to use tar which I've used a bit before but have never had to do this so I'm unsure. I'm trying to remove parent dirs from the backup. example;
Code: tar cvpjf /path/to/backup.tar.bz2 /path/to/the/source I want the backup.tar.bz2 to only contain the contents of source. At the moment the contents of the backup.tar.bz2 have the following file structure /path/to/the/source/files. How can I remove the parent dirs from the backup.tar.bz2? Alternatively, How could I just extract the contents of source with out the above folder structure? at the moment when I extract the backup.tar.bz2, I get the full folder structure in the location that I extracted it to.
View 2 Replies
View Related
Feb 8, 2011
I'm trying to use the dirs command with the +N option. The manual says: dirs [-clpv] [+n] [-n]Without options, displays the list of currently remembered directories. The default display is on a single line with directory names separated by spaces. Direc- tories are added to the list with the pushd command; the popd command removes entries from the list. +n Displays the nth entry counting from the left of the list shown by dirs when invoked without options, starting with zero.
dirs -v shows:
0 /dir1/
1 /dir2/
2 /dir3/
However, dir +n 1, dir +N 1, dir -v +n 1, dir -v +N 1 all give:
[Code]...
View 2 Replies
View Related
Oct 31, 2010
For example I have "/some/dir" which contains user's files and directories. I want to check if there are any files or directories of root. I guess I should use "find" command but what's the full command to find it out?
View 2 Replies
View Related
Jul 7, 2010
I have to format 4 years worth of awstats data "static" for a client and then move it to their new server.I don't want to run the commend to do this 48 times. If possible I would like to use a bash script that uses the folders in a directory so the script knows which year-month to do this for me and which folder to place the output in.
View 5 Replies
View Related
Nov 23, 2010
Now I'm porting a WIFI driver to my platform, MIPS little endian, Linux-2.6.18, uClibc environment for STB. And I'm experiencing some strange symptom. As you know, there are some kind of include files that system provides such like GCC-provided(usually in /usr/include), LIBC-includes(/usr/include), Linux-includes(${LINUX}/include/linux), ASM-includes(${LINUX}/include/asm) and so on, and there are many files resides different directories as the same name (e.g. time.h, types.h, limits.h ...) and many of them has
different contents.
I'm confusing because that some include files are read from unexpected directories.
The command line is like following. $ cross-gcc -o Target -I$(GCC_INC) -I$(LIB_INC) -I$(appl_inc) -isystem $(LINUX)/include -isystem $(LINUX)/include/linux Source.c
And some symbol means:
GCC_INC: directory for GCC include files.
LIB_INC: directory for LIBC include files.
LINUX: Linux kernel directory.
[code]....
As shown above, some include files are read from unexpected directory. This causes some severe compile errors. I've verified these by adding '-E' to the command line. How can I order GCC to read files from where I'm expect?
View 1 Replies
View Related
Jun 27, 2010
Trying to write a shell script called make to read a file called dirs with the following in it
programs
scripts
documents
Read file line by line and make the directories in the current directory when you type ./make dirs if no file is given then program should print usage:
make dirs filename
View 3 Replies
View Related
Mar 23, 2011
Want create script that run in background 5 programs from 5 given dirs and all of them should be in one controlling screen. In other words how via script after created screen and attaching to it via screen -r via script vreate new window within that screen, run given program and detach for new itaration
View 7 Replies
View Related
Jan 28, 2010
I am searching a GUI based "tree view utility" which shows me which directories consume how much hard disc space (cumulative, including recursively the sub directories; including hidden files). Is there such a tool fur Ubuntu/Linux and how do I install it? Is there at least a cmdline command which does the same job in terminal window?
View 1 Replies
View Related
May 2, 2011
I have this message in the syslog from squeeze:
Code:
May 2 21:18:19 squeeze x-session-manager[1732]: WARNING: Could not launch application 'user-dirs-update-gtk.desktop': Unable to start application: Failed to execute child process "xdg-user-dirs-gtk-update" (No such file or directory)
View 1 Replies
View Related
Jan 26, 2011
I've got a Web app on a server, that may dynamically create some directories inside "/public/sites/medias" from the inside of the app. I've got no problem so far to tell Git to ignore everything _actually_ in "public/sites/medias", but the problem is when users begin to create new dirs and add files like these :
/public/sites/medias
---------------------/images
---------------------------/4
[code]....
View 1 Replies
View Related
Jul 22, 2011
suppose in my current directory, I have 50 sub-directories. Now, I am interested only in about 20 of those sub-directories (whose names match a pattern). I would like to recursively list the contents of these 20 sub-directories. How do I do that ? I would like to do this in Solaris 10 and Linux(RHEL 5.x).
View 3 Replies
View Related
Sep 17, 2010
I have installed the files from Betavine - SuSE Linux Drivers and installed it by clicking the rpms and installing now the error is this- Vodafone Mobile Connect needs the following files and dirs with some specific permissions in order to work properly: /etc/ppp/chap-secrets should have 0660 mode, found 0666 /etc/ppp/peers should be readable and writtable by group root user Rob should be a member of group root
View 3 Replies
View Related
Aug 10, 2010
I am going to be given an old "piece of junk" and would like to turn it into a speedy little "toy" to use for things, along with my os x and xp.The computer has windows 98 installed and only has 32MB RAM (could be 64, not sure until im given it) and a 1gig HDD. It also has a CD drive and a Floppy.I would like to speed it to the max, to make it perform (in comparison) as nearly as good as my mac. eg. when apps are opened, they only take a few seconds to pop up. I am looking at Linux distros but am struggling to find one suitable.
I was thinking of Puppy but DSL would probably be more suitable.I would like some recommendations to whether I should give windows a fresh install and try to delete whatever is unnecessary, or just clear it and download a linux and use WINE.
View 9 Replies
View Related
Oct 1, 2010
I just got this message URL...nd so have decided to use firefox sync and chrome sync. Ive installed both of these but how do i go about checking whether or not my data is being backed up? I cant seem to find the servers to log in to.
View 8 Replies
View Related
Jan 10, 2011
I am transtioning from Windows to Ubuntu 10.4 and I was surprised to see that Intuit does not have a Linux build of Quicken. What is the most capable Quicken replacement for Ubuntu? Thanks.
View 3 Replies
View Related
Aug 3, 2010
setting up a dual boot system and would like a gui replacement for grub
View 6 Replies
View Related
Apr 19, 2011
present we have a folder shared between branches (Approx 10G of data) and we're using Windows 2003 with DFS but this has had a number of issues and thus is scheduled to be replaced with a Linux solution for various reasons.I would need a scalable system that will allow me to start off with 5 servers each having a samba?hare to Windows pc's. The 5 servers though must replicate any changes made to the folder. So if server 1 received a new file, it should replicate the change to servers 2-5 etc... Ideally I would also like the shares to allow for AD based permissions.Can anyone recommend a way forward with this? I am currently looking into GlusterFS and lsyncd as two options for the replication
View 1 Replies
View Related
Feb 6, 2010
Just put my second customer on desktop Cent OS 5.4 (x64 this time). The only thing I can not substitute for is iTunes. All he wants to do it to control his iPod (he really does not listen to music on his computer).
View 1 Replies
View Related
Jan 31, 2010
I run a Squeeze system and have recently updated various packages. As far as I can tell one of the changes has deprecated HAL FDI files (used for, among other things, configuring various input devices). I am hence wondering how one should go about configuring such devices --- without having to resort to an xorg.conf file.The two devices in question, an TouchPad and TrackPoint can both be configured via XInput when I log-in, however, it is somewhat tedious. Writing a log-on script to do this also seems rather hacky.So my question is: what is the most elegant way of configuring XInput devices?
View 7 Replies
View Related
Nov 25, 2009
One thing I was disappointed with Fedora 12 was the CD/DVD burning application Brasero. I used this application (version 2.6) on Fedora 11 and every time I created a video DVD, i would get an error 'You do not have the required permissions to use this drive'. Even though I was getting this message, it will burn the DVD successfully and I was able to watch the DVD on TV. But getting this error was annoying. I wrote to the developer Luis Medinas who didn't bother to reply. I posted question in Fedora forums and got no answers.
I came across a note on the internet that they have fixed this bug in version 2.8 that came with Fedora 12, so I installed a fresh copy of Fedora 12. But to my surprise this time Brasero came up with a different error.This time I wrote to another developer Philippe Rouquier and I haven't heard from him either. In next version of Fedora I would be very happy to see a "stable" CD/DVD burning application that won't throw errors.It is very annoying and a big turn off as a user. The only time I use Windows is to author DVD's TMPGEnc Authoring Works 4 simply because in Linux there is no program that is sophisticated and stable enough.
View 14 Replies
View Related
Apr 20, 2010
I've been seeing a lot of posts on Plymouth and I was wondering a few things:
1) What exactly is Plymouth supposed to do? Is it supposed to make a fancy splash screen to replace the scrolling Kernel messages (Which is now just a blinking cursor at the top left), and for that matter...
2) Is it supposed to replace bootlogd (Which has been deprecated - by what, who knows?)? I've seen something about "Plymouth Logger" when I was running the updates on Lucid but I'm not sure how it's supposed to work.
3) I do see a splash screen for Kubuntu when I log off, is the same one supposed to be there when the computer is booting. Also is anyone here familiar with Backtrack? In Backtrack when you boot, you get a splash of the Remote Exploit logo, but in the middle there's a box with the kernel boot messages. Can something similar be implemented in Kubuntu? (Forgive my noobishness)
4) If indeed Plymouth has replaced bootlogd as the boot time logger, will it also fix the problem of incomplete boot logs that existed with bootlogd (And spare us from having to use serial consoles in order to check what modules or drivers are failing at boot time so we can optimize our kernels).
View 5 Replies
View Related
Jul 29, 2010
I am looking for a FTP server replacement that is web based. Something like you see services have out there. I looked at a product called SynaMan from Synametrics Technologies and it really looked like it would do what I wanted but I could never get it to work with Ubuntu.Does anyone have any suggestions. This is for corporate use.Average users just don't get FTP
View 2 Replies
View Related
Dec 5, 2010
There are two things that evince does not do that I need it to do:
1) In dual page viewing mode, it needs to know what to do with the first page. Sometimes the first page is a cover, and sometimes it is not. The facing pages are not correct if the first page is not a cover page, then evince does not place the facing pages on the same screen for me
2) I want to view pages using the best fit mode. I then click on a page in the side pane and the document suddenly changes back to fit page width mode. The "save current settings ad default" does nothing
Because of this, I would like either a fix or a recommendation for a better pdf reader.
View 2 Replies
View Related
Apr 29, 2011
Anyone know of a possible replacement for the Gnome timer applet?
View 8 Replies
View Related