i have a script in my bin directory - so i could use it from any location
I want it to display certain group of files in a directory.
I want to use pushd to put this directory on top of the stack, in case I want to grep something out of the files without using the whole path from the directory that i am in.
I don't want to use cd because i want to use popd to go back to the previous working directoy.
However when i use the pushd in the script, it leaves me in the current working directory. the pushd command does nt put me into the directory that i want. after the script executes, i ma left in the directory that i am working from
Code:
#!/bin/bash
pushd /var/log
todays_session=$(cat /var/log/session.txt)
echo $todays_session
ls -ltr /var/log/ | grep $todays_session
casper bin $ tspin
/var/log ~/bin
02202013
-rw-r--r-- 1 root root 21 Feb 20 06:21 02202013-map.txt
-rw-r--r-- 1 root root 206349 Feb 20 06:21 02202013-accounts.txt
-rw-r--r-- 1 root root 705 Feb 20 06:21 02202013-routers.txt
-rw-r--r-- 1 root root 1843014 Feb 20 06:21 02202013-ips.txt
-rw-r--r-- 1 root root 3250 Feb 20 06:21 02202013-gateways.txt