Read from file specific place in file using inode


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read from file specific place in file using inode
# 1  
Old 07-14-2010
Read from file specific place in file using inode

Hello, I am using tcsh on AIX.
I would like to write a script that does the following:

1. given an inode, how do I find exactly the name of the file?

I know I could do this using ls -i | grep <inode>
but it returns: <inode> <filename>. I need some string manipulation or something to retrieve just the file name.
I tried using variables, but I think variables are defined differently in tsch or something.

2. So, 2 - how to define variables on tcsh (that is personal variables [not env]).

3. How to retrieve number of lines written during a command?
That is, say I activated command1 and it wrote about 200 lines - can I get the number of lines it wrote?

Thank you very much for your help!
# 2  
Old 07-14-2010
ad 1)
Code:
ls -i | awk '/<inode>/{print $2}'

ad 3)
Code:
ls -i | wc -l

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to place specific contents filename within text file

I am trying to use awk to place the contens of a filename in $1 and $2 followed by the data in the text file. Basically, put the filename within the text file. There are over 1000 files in the directory and as of now each file is saved with a unique name but it is not within the file. Thank you... (10 Replies)
Discussion started by: cmccabe
10 Replies

2. Shell Programming and Scripting

How to merge variable data from another file into specific place?

Hello, I'm trying to create multiple commands using a variable input from another file but am not getting any successful results. Basically, file1.txt contains multiple lines with single words: <file1.txt> yellow blue black white I want to create multiple echo commands with these... (8 Replies)
Discussion started by: demmel
8 Replies

3. Shell Programming and Scripting

how read specific line in a file and write it in a new text file?

I have list of files in a directory 'dir'. Each file is of type HTML. I need to read each file and get the string which starts with 'http' and write them in a new text file. How can i do this shell scripting? file1.html <head> <url>http://www.google.com</url> </head> file2.html <head>... (6 Replies)
Discussion started by: vel4ever
6 Replies

4. Shell Programming and Scripting

Take input from read and place it a string in another file

Hi, This is most likely a dumb question but I could not find answer to it elsewhere. I'm building a simple menu with case /esac and want to read user's input: Please enter XYZ ; read XYZ How do I take the value of XYZ and insert it as a variable $XYZ in file file.txt ? I may need to... (9 Replies)
Discussion started by: svetoslav_sj
9 Replies

5. Shell Programming and Scripting

script for inserting line at specific place in file

I use zentyal for my server admin, which is great but zentyal auto-generates config file on boot and hence overwrites any changes made directly to config files. In order to allow multiple user access to a MS ACCESS database, I need to customise the smb.conf file and add the following line to the... (9 Replies)
Discussion started by: barrydocks
9 Replies

6. Shell Programming and Scripting

Read a number from file and place it back

Hi All, I want to read one number from the file. Only one number will be there in the file. then i have to increment the number in my script and put it back in the same file. Is it possible? Can anybody help me? Thanks, Vinay (6 Replies)
Discussion started by: vinayakatj56
6 Replies

7. Shell Programming and Scripting

Jump to a specific place in a file?

If I cat a file And want to go to the first instance of a particular value - what command would I use? And then from that point where I jumped to search for another value - but only search from that point forward not before the file? Thanks~ (2 Replies)
Discussion started by: llsmr777
2 Replies

8. Shell Programming and Scripting

Splitting av file in 2 at specific place based on textpattern

I have a file that I want to split in 2 (with Bourne shell sh) preferably. The file consists of groups of lines separated by newline. The file can vary in length, so I need to check number of groups of text. Here's an example ====EXAMPLE START==== #fruit banana #color yellow #surface smooth... (0 Replies)
Discussion started by: borgeh
0 Replies

9. Shell Programming and Scripting

insert file 1 at a specific place of file 2

Hello, I need to search in file2 for class A : public B { and insert right after that the content of file1. I am a bit lost as to which tools (which bash functions, awk...). I should use. Thanks for some directions here. Regards (1 Reply)
Discussion started by: JCR
1 Replies

10. Programming

How to read specific lines in a bulk file using C file Programming

Please Help me I have a Bulk file containing Hex data I want to read specific lines from that bulk file by ID number. example ID DATE Time data 14 2005/09/28 07:40:08.546 0 5 078B1C 01916C 0FE59C 004B54 0A9670 0D04ED 05B6B4 0E2223... (10 Replies)
Discussion started by: rajan_ka1
10 Replies
Login or Register to Ask a Question