Sponsored Content
Homework and Emergencies Homework & Coursework Questions how to change this looking for mimetype "text/plain" instead of extension *.txt? Post 302514514 by rollinator on Saturday 16th of April 2011 06:52:43 AM
Old 04-16-2011
how to change this looking for mimetype "text/plain" instead of extension *.txt?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Create a Shell script that looks for all text files in your home directory (including subdirectories).
List only text files that all members of your group are able to "read and write".
These files shall be listed in the order "date of last change on file".
The permissions on and the full path of each file shall be listed, too.


2. Relevant commands, code, scripts, algorithms:


3. The attempts at a solution (include all code and scripts):
This is my solution (until now):
Here I'm looking for the file's extension "*.txt" but actually I've to look for the mime-type or so. Therefor the "file command" exists but I've no idea to adopt the mime-type into my script instead of the extension's search?


Code:
#! /bin/bash
 
 
 
 find ~ -name "*.txt" -printf "%M %f %TY%Tm%Td%TH%TM%TS %TY %Tm %Td %TH %TM %p\n" | sort -nk3 |
 awk '/^....rw/{
 
 filecnt = filecnt + 1
 printf ("No. %s", filecnt);
 printf ("  ***  filename: %s", $2 )
 printf ("  ***  filerights: %s", $1);
 printf ("  ***  last change on: %s.%s.%s um %s:%s h\n",$6, $5, $4, $7, $8)
 printf ("  ***  file path: %s\n", $9); 
 
 printf ("\n");
}'

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
HAW Hamburg, Hamburg (Hamburg), Germany, Schneider, BS,http://ds2.etech.haw-hamburg.de/snd/veranst.html

Last edited by pludi; 04-16-2011 at 08:07 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting problem "sort -k 16,29 sample.txt > output.txt"

Hi all, Iam trying to sort the contents of the file based on the position of the file. Example: $cat sample.txt 0101020060731 ## Header record 1c1 Berger Awc ANP20070201301 4000.50 1c2 Bose W G ANP20070201609 6000.70 1c2 Andy CK ANP20070201230 28000.00... (3 Replies)
Discussion started by: ganapati
3 Replies

2. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

3. UNIX for Dummies Questions & Answers

Difference between plain "uniq" and "uniq -u"

Dear all, It's not entirely clear to me from manpage the difference between them. Why we still need "-u" flag? - monkfan (3 Replies)
Discussion started by: monkfan
3 Replies

4. Shell Programming and Scripting

delete " from plain text files

Hi, sorry for bothering with this easy problem but I can't understand... I've a file like this: "4","0x23a3" "5","0x4234" "11","" "20","" "11132","0x6456" I would like to create a file like this: 4,23a3 5,4234 11,999999 20,999999 11132,6456 I've tried: cat INPUT.txt | sed -e... (7 Replies)
Discussion started by: TheMrOrange
7 Replies

5. Shell Programming and Scripting

Help to change the file with "sed" and "awk"

Hi experts I want your help to change the file format to my wanted version, please give me a hand thanks $cat file install pass make os pass make build kernel failed usb storage pass chane to | *install* | *make os* | *make build kernel* | *usb storage* | | pass | pass... (7 Replies)
Discussion started by: yanglei_fage
7 Replies

6. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

7. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

8. Shell Programming and Scripting

Awk,sed : change every 2nd field ":" to "|"

Hi Experts, I have a string with colon delimited, want 2nd colon to be changed to a pipe. data: 101:8:43:4:72:14:41:69:85:3:137:4:3:0:4:0:9:3:0:3:12:3: I am trying with sed, but can change only 1 occurance: echo "101:8:43:4:72:14:41:69:85:3:137:4:3:0:4:0:9:3:0:3:12:3:" | sed 's/:/|/2'... (5 Replies)
Discussion started by: rveri
5 Replies

9. 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

10. Programming

[Python] replicating "sha256 -C checksum_file.txt file.txt"

Hello everyone, Since my python knowledge is limimted, I've challenged myself to learn as much as possible to help me with my carrere. I'm currently trying to convert a shell script to python, just to give myself a task. There is one section of the script that I'm having issues converting and... (2 Replies)
Discussion started by: da1
2 Replies
Dancer::Template::Abstract(3pm) 			User Contributed Perl Documentation			   Dancer::Template::Abstract(3pm)

NAME
Dancer::Template::Abstract - abstract class for Dancer's template engines DESCRIPTION
This class is provided as a base class for each template engine. Any template engine must inherit from it and provide a set of methods described below. TEMPLATE TOKENS
By default Dancer injects some tokens (or variables) to templates. The available templates are: "perl_version" The current running Perl version. "dancer_version" The current running Dancer version. "settings" Hash to access current application settings. "request" Hash to access your current request. "params" Hash to access your request parameters. "vars" Hash to access your defined variables (using "vars"). "session" Hash to access your session (if you have session enabled) INTERFACE
init() The template engine can overload this method if some initialization stuff has to be done before the template engine is used. The base class provides a plain init() method that only returns true. default_tmpl_ext() Template class that inherits this class should override this method to return a default template extension, example: for Template::Toolkit it returns "tt" and for HTML::Mason it returns "mason". So when you call "template 'index';" in your dispatch code, Dancer will look for a file 'index.tt' or 'index.mason' based on the template you use. Note 1: when returning the extension string, please do not add a dot in front of the extension as Dancer will do that. Note 2: for backwards compatibility abstract class returns "tt" instead of throwing an exception 'method not implemented'. User would be able to change the default extension using the "<extension"> configuration variable on the template configuration. For example, for the default ("Simple") engine: template: "simple" engines: simple: extension: 'tmpl' view($view) The default behavior of this method is to return the path of the given view, appending the default template extension (either the value of the "extension" setting in the configuration, or the value returned by "default_tmpl_ext") if it is not present in the view name given and no layout template with that exact name existed. (In other words, given a layout name "main", if "main" exists in the layouts dir, it will be used; if not, "main.tmpl" (where "tmpl" is the value of the "extension" setting, or the value returned by "default_tmpl_ext") will be looked for.) view_exists($view_path) By default, Dancer::Template::Abstract checks to see if it can find the view file calling "view_exists($path_to_file)". If not, it will generate a nice error message for the user. If you are using extending Dancer::Template::Abstract to use a template system with multiple document roots (like Text::XSlate or Template), you can override this method to always return true, and therefore skip this check. layout($layout, $tokens, $content) The default behavior of this method is to merge a content with a layout. The layout file is looked for with similar logic as per "view" - an exact match first, then attempting to append the default template extension, if the view name given did not already end with it. render($self, $template, $tokens) This method must be implemented by the template engine. Given a template and a set of tokens, it returns a processed string. If $template is a reference, it's assumed to be a reference to a string that contains the template itself. If it's not a reference, it's assumed to be the path to template file, as a string. The render method will then have to open it and read its content (Dancer::FileUtils::read_file_content does that job). This method's return value must be a string which is the result of the interpolation of $tokens in $template. If an error occurs, the method should trigger an exception with "die()". Examples : # with a template as a file $content = $engine->render('/my/template.txt', { var => 42 }; # with a template as a scalar my $template = "here is <% var %>"; $content = $engine->render($template, { var => 42 }); AUTHOR
This module has been written by Alexis Sukrieh, see Dancer for details. perl v5.14.2 2012-03-31 Dancer::Template::Abstract(3pm)
All times are GMT -4. The time now is 04:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy