cat /proc/ files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cat /proc/ files
# 1  
Old 09-06-2007
cat /proc/ files

Hi,
I need to write a shell script that should lists only the files that starts with alphabet from the /proc dir and then I have to cat those files and redirect to a file.

But my below script is not working. It is reading the first file properly but not the subsequent files. Please throw a light on this for me:

Code:
for file in "`ls -l /proc/ | grep "^-" | awk '{ print $8 }' | grep "^[a-zA-Z]"`"
do   
   cat /proc/"$file" >> file.txt
done

# 2  
Old 09-06-2007
Perhaps this.

Code:
for file in `find /proc/* -prune -type f -name "[a-zA-Z]*"`
do
  name=${file##/proc/}
  cat "$file" > ${name}.txt 2> /dev/null
done

# 3  
Old 09-13-2007
Thanks a lot Vino.
Do we need to specify the "/*" after "/proc" ? Without that also "find" command works. Does it serve any precautionary step in the script? Please add your comments.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cat N files in a folder

I am new to Linux and I am trying to cat only N files in a folder. N is dynamically given number at runtime. If I give N as 2 then cat only 2 files in the folder and If I give N as 5 then cat only 5 files in the folder. Is there any way to do that? (6 Replies)
Discussion started by: KMusunuru
6 Replies

2. IP Networking

Cat /proc/sys/net/ipv4/ip_local_port_range

Hello, /proc/sys/net/ipv4/ip_local_port_range returns 32000 - 61000, i have a client TCP and a Server TCP. i have used bind() only on the server, the port of socket client is given by the OS that's it ? it retrieves this port from this range (/proc/sys/net/ipv4/ip_local_port_range) ? ... (5 Replies)
Discussion started by: chercheur111
5 Replies

3. Solaris

Zero link count files in proc

Hi Experts, I had encountered an issue where the zero link process was holding too much amount of data on a Solaris server. I was able to terminate the process after which the space of the file system was released. 40G /proc/8567/fd/2 Can you please let me know if there are any... (11 Replies)
Discussion started by: dhanu1985
11 Replies

4. UNIX for Dummies Questions & Answers

Edit files with cat

Hi, sometimes one wants to edit files while still seeing output of earlier commands in terminal. I've found out that cat test && cat - >> test does the trick for displaying file content and adding lines but I believe I saw a much cooler command that was also able to erase lines from files. I cannot... (6 Replies)
Discussion started by: scarleo
6 Replies

5. Solaris

Impact of zero link count files in proc

Greetings I want to confirm about HUGE and old files with linkcount 0 in proc file system. what is their impact on size of root File system? (3 Replies)
Discussion started by: mr_os
3 Replies

6. Shell Programming and Scripting

cat certain files in directories to files named after the dir?

Hi all, I have a directory with many subdirectories each named like so: KOG0001, KOG0002, ...KOG9999. Each of these subdirectories contain a variable number two kinds of files (nuc and prot) named like so: Capitella_sp_nuc_hits.fasta (nuc) and Capitella_sp_prot_hits.fasta (prot). The... (2 Replies)
Discussion started by: kmkocot
2 Replies

7. UNIX for Dummies Questions & Answers

_/proc/stat vs /proc/uptime

Hi, I am trying to calculate the CPU Usage by getting the difference between the idle time reported by /proc/stat at 2 different intervals. Now the 4th entry in the first line of /proc/stat will give me the 'idle time'. But I also came across /proc/uptime that gives me 2 entries : 1st one as the... (0 Replies)
Discussion started by: coderd
0 Replies

8. UNIX for Dummies Questions & Answers

Difference between cat , cat > , cat >> and touch !!!

Hi Can anybody tell the difference between Difference between cat , cat > , cat >> and touch command in UNIX? Thanks (6 Replies)
Discussion started by: skyineyes
6 Replies

9. UNIX for Dummies Questions & Answers

cat files

Hi, I was a typical Windows guy. Like to do things just by clicking my mouse:cool:. I got a new job now...where they are big on unix. I am trying to wet my fingures now with unix. Haven't taken the dive yet. I am trying to find a solution for this problem. Please help me with some... (4 Replies)
Discussion started by: sandeep78
4 Replies

10. Shell Programming and Scripting

KSH CAT Two files into one

Quick question, File A has one line (10 charachters), File B has one line (10 charachters). how do a concat these two files together to produce a file (File C) that has the contents of Files A + B together onto one line of 20 Charachters if I use: cat FileA FileB > FileC I get the... (5 Replies)
Discussion started by: kshelluser
5 Replies
Login or Register to Ask a Question