help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] flummoxed


From: Brian Tew
Subject: [Help-bash] flummoxed
Date: Thu, 09 Oct 2014 04:14:42 -0500
User-agent: edbrowse/3.4.4

Brian Tew 
address@hidden

Ok I have this tiny bash script callef lf to list files only (no sub 
directories).
Problem is that it lists the files in my home dir no matter what dir I am in.
I want it to list the files in the current directory.
The lf command is in /usr/local/bin, and there are no aliases or functions with 
that  name.
I also put an exact copy of lf called lfx in /usr/local/bin except it has 'set 
-x' in it.
Here it the output of my tests below.
I am flummoxed.
Thanks for any help.

Script started on Mon 06 Oct 2014 09:39:44 AM CDT
~$ls
home1
home2
tmp
ttt
typescript
~$lf
home1
home2
typescript
~$cd tmp
tmp$ls
tmp1
tmp2
tmp$lf
home1
home2
typescript
tmp$cd
~$ls
home1
home2
tmp
ttt
typescript
~$lf
home1
home2
typescript
~$cd tmp
tmp$ls
tmp1
tmp2
tmp$lf
home1
home2
typescript
tmp$which lf
/usr/local/bin/lf
tmp$cd /usr/local/bin
bin$cat lf
for f in *; do [[ -d "$f" ]] || echo "$f"; done
bin$cat lfx
set -x
for f in *; do [[ -d "$f" ]] || echo "$f"; done
bin$cd
~$ls
home1
home2
tmp
ttt
typescript
~$lfx
++ for f in '*'
++ [[ -d home1 ]]
++ echo home1
home1
++ for f in '*'
++ [[ -d home2 ]]
++ echo home2
home2
++ for f in '*'
++ [[ -d tmp ]]
++ for f in '*'
++ [[ -d ttt ]]
++ for f in '*'
++ [[ -d typescript ]]
++ echo typescript
typescript
~$cd tmp
tmp$ls
tmp1
tmp2
tmp$lfx
++ for f in '*'
++ [[ -d home1 ]]
++ echo home1
home1
++ for f in '*'
++ [[ -d home2 ]]
++ echo home2
home2
++ for f in '*'
++ [[ -d tmp ]]
++ for f in '*'
++ [[ -d ttt ]]
++ for f in '*'
++ [[ -d typescript ]]
++ echo typescript
typescript
tmp$uname -a
Linux Laggy 3.11.0-26-generic #45-Ubuntu SMP Tue Jul 15 04:02:06 UTC 2014 
x86_64 x86_64 x86_64 GNU/Linux
tmp$bash --version
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
tmp$exit

Script done on Mon 06 Oct 2014 09:46:21 AM CDT



reply via email to

[Prev in Thread] Current Thread [Next in Thread]