Sponsored Content
Full Discussion: listing files question
Top Forums UNIX for Dummies Questions & Answers listing files question Post 302277013 by Fortune on Thursday 15th of January 2009 06:45:22 AM
Old 01-15-2009
listing files question

hello im new to linux programming trying to list files in a directory i current have the code to list all the files but i do not want the hidden files to show such as a file named .openoffice.org2.0 for example, can anyone help me or point me in the right direction


#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <stdio.h>
int recls(void);
int main(void){
recls();
}
int recls(void) {
DIR *dir;
struct dirent *dirslot;
dir=opendir(".");
while (1) {
dirslot=readdir(dir);
if (dirslot==NULL) return 1;
printf("%s\n", dirslot->d_name);
}
}
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Another Listing Question

If I had a bunch of files called: report06/02/99, report 06/09/00, report07/08/00, report0608/99. How would I be able to list only the files that begin with "report" for the month of June 1999. It's for my shell scripting program. Thanks in advance. b (1 Reply)
Discussion started by: Astudent
1 Replies

2. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies

3. UNIX for Dummies Questions & Answers

Quick listing question

Just a quick question. Is there a command that just lists the folders in a directory. I know of 'ls -p' that shows the directories with a '/' at the end. Though i would just like to have a list of the folders instead of everything else in that folder. Thanks (3 Replies)
Discussion started by: Jaken
3 Replies

4. UNIX for Advanced & Expert Users

listing files excluding files from control file

I have a directory named Project.I have a control file which contains valid list of files.I would like list the files from directory Project which contains files other than listed in the control file. Sample control file: TEST SEND SFFFILE CONTL The directory contains followign... (15 Replies)
Discussion started by: ukatru
15 Replies

5. UNIX for Dummies Questions & Answers

listing certain files

How would i list the files that begin with a and end with .erc with 4 characters between (5 Replies)
Discussion started by: trob
5 Replies

6. Shell Programming and Scripting

perl script for listing files and mailing the all files

Hi, I am new to perl: I need to write perl script to list all the files present in directory and mail should be come to my inbox with all the files present in that directory. advanced thanks for valuable inputs. Thanks Prakash GR (1 Reply)
Discussion started by: prakash.gr
1 Replies

7. SCO

CPIO listing from tape question...

Hi. I have this old server onto which i needed to list the content of a tape. This is a SCO box (SCO_SV 3.2 5.0.6 i386) and backup was done using cpio. #tape status status : ready beginning-of-tape soft errors : 0 hard errors : 0 underruns : 0 #dtype /dev/rct0 /dev/rct0 ... (5 Replies)
Discussion started by: Stephan
5 Replies

8. Shell Programming and Scripting

Simple listing directory question

I have a very basic question: How do I list all the directories in the following order? If I do ls -l I get different results than I want to achieve. dir.1 dir.2 dir.3 dir.4 dir.5 dir.6 dir.7 dir.8 dir.9 dir.10 dir.11 dir.12 dir.13 dir.14 (4 Replies)
Discussion started by: jville
4 Replies

9. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

10. UNIX for Advanced & Expert Users

Formatted Directory Listing Question

Greetings to you. I have a quick question for the community today ;) I'm interested in the following format for recursive output from a command such as "ls" or "dir" when pointed to a folder: ...but there doesn't seem to be coverage for this type of output formatting in the manpages. Maybe... (11 Replies)
Discussion started by: LinQ
11 Replies
FSDB(8) 						    BSD System Manager's Manual 						   FSDB(8)

NAME
fsdb -- FFS debugging/editing tool SYNOPSIS
fsdb [-d] [-f] [-r] fsname DESCRIPTION
The fsdb utility opens fsname (usually a raw disk partition) and runs a command loop allowing manipulation of the file system's inode data. You are prompted to enter a command with fsdb (inum X)> where X is the currently selected i-number. The initial selected inode is the root of the file system (i-number 2). The command processor uses the editline(3) library, so you can use command line editing to reduce typing if desired. When you exit the command loop, the file system superblock is marked dirty and any buffered blocks are written to the file system. The following options are available: -d Enable additional debugging output (which comes primarily from fsck(8)-derived code). -f Left for historical reasons and has no meaning. -r Open the file system read/only, and disables all commands that would write to it. COMMANDS
Besides the built-in editline(3) commands, fsdb supports these commands: help Print out the list of accepted commands. inode i-number Select inode i-number as the new current inode. back Revert to the previously current inode. clri i-number Clear i-number. lookup name cd name Find name in the current directory and make its inode the current inode. Name may be a multi-component name or may begin with slash to indicate that the root inode should be used to start the lookup. If some component along the pathname is not found, the last valid directory encountered is left as the active inode. This command is valid only if the starting inode is a directory. active print Print out the active inode. blocks Print out the block list of the active inode. Note that the printout can become long for large files, since all indirect block pointers will also be printed. findblk disk_block_number ... Find the inode(s) owning the specified disk block(s) number(s). Note that these are not absolute disk blocks numbers, but offsets from the start of the partition. uplink Increment the active inode's link count. downlink Decrement the active inode's link count. linkcount number Set the active inode's link count to number. ls List the current inode's directory entries. This command is valid only if the current inode is a directory. rm name del name Remove the entry name from the current directory inode. This command is valid only if the current inode is a directory. ln ino name Create a link to inode ino under the name name in the current directory inode. This command is valid only if the current inode is a directory. chinum dirslot inum Change the i-number in directory entry dirslot to inum. chname dirslot name Change the name in directory entry dirslot to name. This command cannot expand a directory entry. You can only rename an entry if the name will fit into the existing directory slot. chtype type Change the type of the current inode to type. Type may be one of: file, dir, socket, or fifo. chmod mode Change the mode bits of the current inode to mode. You cannot change the file type with this subcommand; use chtype to do that. chflags flags Change the file flags of the current inode to flags. chown uid Change the owner of the current inode to uid. chgrp gid Change the group of the current inode to gid. chgen gen Change the generation number of the current inode to gen. btime time mtime time ctime time atime time Change the creation (birth), modification, change, or access time (respectively) on the current inode to time. Time should be in the format YYYYMMDDHHMMSS[.nsec] where nsec is an optional nanosecond specification. If no nanoseconds are specified, the birthnsec, mtimensec, ctimensec, or atimensec field will be set to zero. Note that btime is available on UFS2 file systems only. quit, q, exit, <EOF> Exit the program. SEE ALSO
editline(3), fs(5), clri(8), fsck(8) HISTORY
The fsdb utility uses the source code for fsck(8) to implement most of the file system manipulation code. The remainder of fsdb first appeared in NetBSD, written by John T. Kohl. Peter Wemm ported it to FreeBSD. BUGS
Manipulation of ``short'' symlinks has no effect. In particular, one should not try changing a symlink's type. You must specify modes as numbers rather than symbolic names. There are a bunch of other things that you might want to do which fsdb does not implement. WARNING
Use this tool with extreme caution--you can damage an FFS file system beyond what fsck(8) can repair. BSD
August 24, 2006 BSD
All times are GMT -4. The time now is 07:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy