Find all "regular" files open for write on solaris?


 
Thread Tools Search this Thread
Operating Systems Solaris Find all "regular" files open for write on solaris?
# 1  
Old 12-02-2010
Find all "regular" files open for write on solaris?

How do I find all "regular" files on solaris(8) that are open for write ( +read as well).

I tried using pfiles, and lsof commands, but not sure how to get exactly what I wanted.

Code:
 
ps -e | awk '{ print $1 }' | xargs -i pfiles {} 2>/dev/null

# 2  
Old 12-03-2010
Code:
pfiles /proc/* | grep "^ */" | sort -u

# 3  
Old 12-03-2010
I get no output.
Quote:
pfiles /proc/*
part is working fine.
But
Quote:
| grep "^ */"
part does not return anything.

Can you check it on your end. Also I am not sure what you are trying to do with that second argument,, if you explain I can give it a try.
# 4  
Old 12-03-2010
I have no Solaris 8 to check. My command works fine with Solaris 10 and 11. The grep is extracting filenames from the pfiles output.

Can you post a sample output of
Code:
pfiles /proc/*

on Solaris 8 ?
# 5  
Old 12-04-2010
Here is first few lines of output.

Code:
$>  pfiles /proc/* 2>/dev/null | more
1194:   -ksh
  Current rlimit: 8192 file descriptors
   0: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   1: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   2: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
  63: S_IFREG mode:0600 dev:85,3 ino:236544 uid:3051 gid:3051 size:3064
      O_RDWR|O_APPEND|O_LARGEFILE FD_CLOEXEC
1225:   pfiles /proc/0 /proc/1 /proc/103 /proc/1124 /proc/1125 /proc/1126 /pro
  Current rlimit: 8192 file descriptors
   0: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   1: S_IFIFO mode:0000 dev:287,0 ino:14203390 uid:3051 gid:3051 size:0
      O_RDWR
   2: S_IFCHR mode:0666 dev:85,0 ino:112451 uid:0 gid:3 rdev:13,2
      O_WRONLY|O_LARGEFILE
   3: S_IFDIR mode:0500 dev:285,0 ino:8150 uid:3051 gid:3051 size:8208
      O_RDONLY|O_NDELAY|O_LARGEFILE FD_CLOEXEC
1226:   more
  Current rlimit: 8192 file descriptors
   0: S_IFIFO mode:0000 dev:287,0 ino:14203390 uid:3051 gid:3051 size:0
      O_RDWR
   1: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
   2: S_IFCHR mode:0620 dev:85,0 ino:112719 uid:3051 gid:7 rdev:24,3
      O_RDWR|O_LARGEFILE
13173:  /<process_dir>/<process.exe> <startup_commmand_options>
  Current rlimit: 8192 file descriptors
   0: S_IFCHR mode:0666 dev:85,0 ino:112721 uid:0 gid:0 rdev:24,5
      O_RDWR|O_LARGEFILE
   1: S_IFCHR mode:0666 dev:85,0 ino:112721 uid:0 gid:0 rdev:24,5
      O_RDWR|O_LARGEFILE
   2: S_IFREG mode:0666 dev:85,3 ino:1036466 uid:3051 gid:3068 size:0
      O_RDWR|O_APPEND
   3: S_IFREG mode:0771 dev:85,3 ino:1724623 uid:3051 gid:3051 size:0
      O_RDWR


Last edited by kchinnam; 12-04-2010 at 12:13 AM.. Reason: formatting
# 6  
Old 12-04-2010
Well, pfiles started to show the full path with Solaris 10. For older releases, the simpler solution would be to install lsof from sunfreeware.
# 7  
Old 12-05-2010
We do have lsof installed. What do I need to do to get only open files for writing from lsof output ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find files in sub dir with tag & add "." at the beginning [tag -f "Note" . | xargs -0 {} mv {} .{}]

I am trying find files in sub dir with certain tags using tag command, and add the period to the beginning. I can't use chflags hidden {} cause it doesn't add period to the beginning of the string for web purpose. So far with my knowledge, I only know mdfind or tag can be used to search files with... (6 Replies)
Discussion started by: Nexeu
6 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. Shell Programming and Scripting

Expect: spawn id exp5 not open while executing "expect "$" { send "sudo su -\r" }"

Hi All, i am trying to ssh to a remote machine and execute certain command to remote machine through script. i am able to ssh but after its getting hung at the promt and after pressing ctrl +d i am gettin the out put as expect: spawn id exp5 not open while executing "expect "$" {... (3 Replies)
Discussion started by: Siddharth shivh
3 Replies

4. Shell Programming and Scripting

Problem with find command "find: cannot open"

Hello Guys , I am trying to run below find command in one of my SH script on a HP UX machine. find /tmp -type f -name "MGCA*.log" -prune -exec rm -f {} \; 2>&1 I want this to check my tmp directory and delete MGCA log files .But below error message is printed on Promt :- find: cannot... (2 Replies)
Discussion started by: himanshu sood
2 Replies

5. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

6. UNIX for Dummies Questions & Answers

"-maxdepth 1" argument for Solaris find. Other way to restrict find in only one directory?

Hi I wish to find only files in dir /srv/container/content/imz06/. It means exclude subfolder /srv/container/content/imz06/archive/ > uname -a SunOS testbox6 5.10 Generic_139555-08 sun4v sparc SUNW,Sun-Blade-T6320Its Solaris default "find" > find /srv/container/content/imz06/* -name... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

7. Solaris

Solaris 10 - Unable to boot the system "panic: cannot open /kernel/amd64/unix"

Hi All, I have installed Solaris 10 on my AMD 64 3000+ system. I was playing with grub commands eeprom and bootadm commands. I screwed my boot-file and now am unable to boot the system. Gets error msg as "panic: cannot open /kernel/amd64/unix". I booted the system is filesafe and tried update the... (2 Replies)
Discussion started by: Manjunath K V
2 Replies

8. Shell Programming and Scripting

Find closing brace "{" of a given open brace "{"

There is a file as: ....... some text timing () { capacitance : 9.0; incap : 0.8; cell_fall () { values ("8.9","7.8"); } } ........ some more text ####### Is there a way to directly find closing brace "{" of timing () block "{" ? (2 Replies)
Discussion started by: nehashine
2 Replies

9. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

10. Shell Programming and Scripting

communicating wth another user aside from "wall" and "write"

Hi, Can anyone suggest a Unix command or c-shell algorithm to simulate to behavior of "wall" command minus the "all users"? What I'm trying to do is to send a notice to just one particular user but i dont want other remotely-logged-on users to receive the message (on the pseudo-terminals). I... (6 Replies)
Discussion started by: Deanne
6 Replies
Login or Register to Ask a Question