The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 06:06 PM
inconsistent ls command display at the command prompt & running as a cron job rajranibl SuSE 5 07-30-2007 08:26 AM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr HP-UX 1 10-16-2006 04:16 PM
How to use more than one MPE command STREAM with Unix command in a single shell? bosskr Shell Programming and Scripting 0 09-19-2006 09:44 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2006
princssashes princssashes is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 3
Unhappy ls command help

Okay so I am very confused as to how to do this it says it is an exercise in my book but never talks about it or explains it please help I have tried everything every combination i can think of.

find out which of these filename paths exist using the ls command and save the list to a file in the pwd name 'existentFiles'

/etc/magic /sbin/fsck /boot/grub/menu.lst /usr/share/games/wombat /var/cache/man/index.db /usr/bin/defcon

with parameters that aside from the file name args, only the -1 flag for the ls command should be used.

I have no clue what the command would be I have tried
ls -1 /etc/magic /sbin/fsck /boot/grub/menu.lst /usr/share/games/wombat /var/cache/man/index.db /usr/bin/defcon > existentFiles

and many variations but nothing........

then the 2nd part is to find out from the same list which pats exist and which dont using the same parameters except adding both a list in the pwd named existentFiles and a list in the pwd for nonexistantFiles

Please help
  #2 (permalink)  
Old 10-23-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
hey the option is not -1, its -l (el)...use it...it'll work fine

for the second part, after >existentfiles, type 2>nonexistentfiles it will send the error output to nonexistentfiles
  #3 (permalink)  
Old 10-23-2006
princssashes princssashes is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 3
it is actually -1 which is a new line for every file
  #4 (permalink)  
Old 10-23-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
hmmm...i'll chk it out n let u know...am also a newbie
  #5 (permalink)  
Old 10-23-2006
Glenn Arndt's Avatar
Glenn Arndt Glenn Arndt is offline Forum Advisor  
Anomalous Lurker
  
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
Are you allowed to use "cut"?
Code:
ls -1 /etc/magic /sbin/fsck /boot/grub/menu.lst /usr/share/games/wombat /var/cache/man/index.db /usr/bin/defcon 2>&1 1>existingFiles | cut -d" " -f1 >nonexistingFiles
If not, try
Code:
ls -1 /etc/magic /sbin/fsck /boot/grub/menu.lst /usr/share/games/wombat /var/cache/man/index.db /usr/bin/defcon 2>&1 1>existingFiles 2>nonexistingFiles
The drawback there is that instead of a simple list of files in "nonexistingFiles", you'll have a list like:
Code:
/boot/grub/menu.lst not found
/var/cache/man/index.db not found
  #6 (permalink)  
Old 10-23-2006
NSKerben NSKerben is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 7
use grep -v ?
  #7 (permalink)  
Old 10-23-2006
BOFH BOFH is offline Forum Advisor  
Registered User
  
 

Join Date: Feb 2005
Location: Broomfield, CO
Posts: 406
Code:
#!/bin/ksh

if [ -f existentFiles ]
then
  rm existentFiles
fi

for a in /etc/magic /sbin/fsck /boot/grub/menu.lst /usr/share/games/wombat /var/cache/man/index.db /usr/bin/defcon

do
  if ( ls $a > /dev/null 2>&1 )
  then
    echo $a >> existentFiles
  fi
done
On my Mandrake box (using /bin/bash as the first line) I get:

Code:
$ cat existentFiles
/sbin/fsck
On my OpenBSD box (using /bin/ksh as the first line) I get:

Code:
$ cat existentFiles
/etc/magic
/sbin/fsck
Carl
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:35 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0