ok the assignment question:
That English paper you were writing on the works of Lewis Carroll is due in a few hours and you have forgeotten the name of the text file in which you has written a number of quotations to use in your paper. Luckily, you know that the file is somewhere in your ~/UnixCourse directory or in some subdirectory directly or indeirently within it. You also know that the file name ended in '.txt'. You are pretty sure that you could recognize the file from just the first line.
You seem to recall having heard that there is a Unix command head that will print the first few lines of any file and suspect that, with the proper parameters, it could be used to print just the first line. (Hint - part of your task in this question is to show that you can use the built-in Unix help facilities.)
find command problems
redirectionAsst
But you really don't want to type that command out for every file or even every directory. What command would you give to produce a listing of the names of all the text files in ~/UnixCourse or its subdirectories (possibly nested several layers deep) followed immediately by the first line of text within that file? E.g., to produce a listing looking like this:
/home/yourname/UnixCourse/foo.txt
When in the course of human development
/home/yourname/UnixCourse/Quotations/bar.txt
Curiouser and curiouser!
finding a file and the first line of the text
Note that the output format must look like the example above. (That's not unreasonable, as one of the things you should have learned from this lesson is that the output of one command is often fed into later commands, which must be able to read it.) In particular, solutions that add extreneous characters around the file name (e.g., << or ==>) are not correct.
I was able to come up with :
Unfortunitly , this is bring up the ==> that is noted above that is incorrect.
How do i get rid of the ==> ? or is there another command that might work?
Last edited by Yogesh Sawant; 04-20-2009 at 05:49 AM..
Reason: added code tags
I have a text file with hundreds of 32-character hash codes in it, each terminated with a linefeed (/l, or ^M).
185ead08e45a5cbb51e9f7b0b384aaa2
57643e1a17252a9fc746d49c3da04168
60cba11d09221d52aaabb5db30f408a2
2b75ee6e5c2efc31b4ee9a190d09a4df
...... etc.
I want to create a file for each... (6 Replies)
Hi
We are doing the migration of DMX3 disks to DMX4 disks using migratepv. We are not using GPFS but we have gpfs disks present in the server. Can anyone advise how to get rid of GPFS in both the servers cbspsrdb01 and cbspsrdb02. I will do migratepv for the other disks present in the servers... (2 Replies)
Hi all,
I am new to unix....pls help me with this.
I have a binary file generating output by passing arguments in bash.when i open the output file in VI i can see that ^m is included in between most of lines,as a result when i pass this file to my java application it dosent parse the data... (3 Replies)
ex: I have list of files in a folder.
abc_def_geh_.txt
abc_.txt
abc_def_geh_12345_.txt
ab134c_d345345ef_444geh_12345_.txt
i need to rename all files to get rid of the _ before .txt
result should look like this:
abc_def_geh.txt
abc.txt
abc_def_geh_12345.txt... (2 Replies)
Hello I am working aon script, that tells me how many users or on the system when i run it.
The script is
#!/bin/bash
w | cut -f 1 -d ' ' |sort -u | wc -l
When ran it shows 16 users including myself and a line of white space.
I was wondering what I need to add to remove my user... (2 Replies)
hi,
I want to get rid of ' from my variable value in ksh, and I also want to read the value on the right hand side of = into a variable
thanks (10 Replies)
Hi All,
Im selecting a large record from a table and putting it in a file in the unix box. The file has a hidden character "^[[D " present in it. Can any one help me in getting rid of the character
Thanks in advance, (4 Replies)
Hello,
I'm able to trim down the log message to "192.168.1.0.", but can't get rid off the last period.
Can any one help me on the syntax to get rid of the last period?
Basically, I want "192.168.1.0" instead of "192.168.1.0."
Thanks, (4 Replies)
I have to process a data file in Ab Initio. This data file is pipe delimited. BUt the file may have a Disclaimer line at the end. So before picking it for processing, I need to check if this line is there I need to remove it. ANy suggestions.
Thanks
Shalu (1 Reply)
Hello everybody
I have a very annoying problem on my Solaris (Unix in general) servers. When I open a shell and press the backspace button, it results in a ^H character being printed on screen. I can resolve it by typing stty erase <backspace>, but does anyone know how I can prevent the... (3 Replies)