Sponsored Content
Homework and Emergencies Homework & Coursework Questions File Looping - Looking for executable files - Need help Post 302521912 by Bob07 on Thursday 12th of May 2011 05:45:42 PM
Old 05-12-2011
File Looping - Looking for executable files - Need help

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

Hello all, I have posted here before and really was blown away by the amount of assistance I received. I was able to finish my homework without a problem! But, yet again, our instructor has given us an assignment a lot of agreed was a bit too advanced for us. I'm in need of some help.

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

Create a shell script to loop through all the files and display

Sequence # Name Size Flag
========== ====================== ========= ==============

Flag should be "Yes" for executable files and "No" for non-executable files.
Image


2. Relevant commands, code, scripts, algorithms:
ls, grep, printf, while loop


3. The attempts at a solution (include all code and scripts):

Here's my sad attempt at it:

s=1

while [ $s -le 10 ]
do
printf "Sequence\n========\n%4d\n" $s
name=`cut -d" " -f1 RevFile | rev`
printf "Name\n===========\n%4s" $name

size=`ls -l | awk -F" " '{print $5}'`
printf "Size\n===========\n$4s" $size

printf "Flag\n==========\n"

let s++

done

WHAT WORKS:

The Sequence has no problem incrementing to the number I indicated. I set it up as a test because I knew the directory we were using contained hundreds of files and I wanted to keep it at a low number. File names are also showing up, but that's it, and even they are having problems lining up correctly under the "=======".

The "rev" command is in place because I actually had a file already set up with the directory in reverse so if I needed file names all I had to do was cut that first field, reverse that, and I had it. I'm sure there's an easier and better method out there, such as awk, but I've allowed frustration of not knowing what to do to get to me.

What is NOT working:

File size isn't showing up as intended and I don't have the flag portion set up. I need to get this thing straightened out first before I start working on the actual fields because right now it's printing as one whole single line and seperating into columns like the instructor is wanting us to do. I gotta be honest here, the guy HAS NOT covered enough material for us to be able to pull something like this off.

So basically I'd like to know what I should be doing in order to line the columns up the way they need to be. I'd be extremely grateful for any and all help!!!!

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Baker College of Jackson, Jackson MI, U.S., Instructor S. Sadiq, LUX 211

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

looping files

Hi, I have a file a.lst which lists all files. as a.dat b.dat c.dat I want to process these files mentioned in the list file in a loop. Say I want to display only the first line of all the files a.dat , b.dat, c.dat. How can I go about it? Please help. (5 Replies)
Discussion started by: dharmesht
5 Replies

2. UNIX for Dummies Questions & Answers

Executable files

This question always confuses me :- Suppose I write a program and compile it on a machine with operating system A and processor B will the exe file run on a machine with operating system A2 but processor B operating system A but processor B2 operating system A2 and processor B2........ ... (9 Replies)
Discussion started by: nervous
9 Replies

3. Shell Programming and Scripting

Looping through files...

I posted this in the Solaris forum, but I don't think it's platform specific, so I'm posting it here. Here is the situation. We are a company that has been using a professional publishing system, the software is called "ProType". It runs on Solaris 2.4, however it is no longer supported and we... (6 Replies)
Discussion started by: Fred Goldman
6 Replies

4. UNIX for Dummies Questions & Answers

executable files

hello. My question, basically is: what is the definition of unix/linux exec files, or what makes a file executable? More specifically, must a unix source file that was compiled using gcc have exec permissions in order to be considered executable? Is it right to say that a unix/linux exec file... (1 Reply)
Discussion started by: nadavkri
1 Replies

5. Shell Programming and Scripting

Automatically select records from several files and then run a C executable file inside the script

Dear list its my first post and i would like to greet everyone What i would like to do is select records 7 and 11 from each files in a folder then run an executable inside the script for the selected parameters. The file format is something like this 7 100 200 7 100 250 7 100 300 ... (1 Reply)
Discussion started by: Gtolis
1 Replies

6. Shell Programming and Scripting

looping through files

I am writing a ksh which has to load 7 files(.dat files) from input directory into oracle tables using sql loader. The process has to take each file at a time and once if it is loaded succesfully using sql loader into oracle tables then the process has to pick next file and load it into oracle... (2 Replies)
Discussion started by: vpv0002
2 Replies

7. UNIX for Dummies Questions & Answers

looping through file and creating seperate files

Hi, My first post!! I have a files with header, something like this Header_Row AMC|D1|D2|D2 AAO|D3|D4|D5 AMC|D6|D7|D8 AAO|D9|D10|D11 . . . . . and millions fo records thereafter like this. I want to read the above file in a loop and write the lines having AMC into another... (1 Reply)
Discussion started by: amitbakre
1 Replies

8. Shell Programming and Scripting

While or For with looping contructs? to create files from contents of a text file

Hi so far I created this script: vi loop.beta.sh for i in `cat extract.filenames.tabc` do echo $i done>$i === This is the original text file. $ more tabc.txt -rwx------- 1 alice staff 1586 2010-11-05 02:27 request-key .conf -rwx------- 1 ted staff 126 ... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

9. Shell Programming and Scripting

Looping the files for getting the file size information

Am using Linux 3.10 years.txt is input source file which has the list of year like below 2013 2014 2015 2016 Other Input files are XX_TEST1_YR2016_01012018.csv XX_TEST1_YR2015_01012018.csv XX_TEST1_YR2014_01012018.csv XX_TEST1_YR2013_01012018.csv XX_TEST2_YR2016_01012018.csv... (2 Replies)
Discussion started by: weknowd
2 Replies
DEBCONF-MERGETEMPLATE(1)					      Debconf						  DEBCONF-MERGETEMPLATE(1)

NAME
debconf-mergetemplate - merge together multiple debconf template files SYNOPSIS
debconf-mergetemplate [options] [templates.ll ...] templates DESCRIPTION
Note: This utility is deprecated. You should switch to using po-debconf's po2debconf program. This program is useful if you have multiple debconf templates files which you want to merge together into one big file. All the specified files will be read in, merged, and output to standard output. This can be especially useful if you are dealing with translated template files. In this case, you might have your main template file, plus several other files provided by the translators. These files will have translated fields in them, and maybe the translators left in the english versions of the fields they translated, for their reference. So, you want to merge together all the translated templates files with your main templates file. Any fields that are unique to the translated files need to be added in to the correct templates, but any fields they have in common should be superseded by the fields in the main file (which might be more up-to-date). This program handles that case properly, just list each of the translated templates files, and then your main templates file last. OPTIONS
--outdated Merge in even outdated translations. The default is to drop them with a warning message. --drop-old-templates If a translation has an entire template that is not in the master file (and thus is probably an old template), drop that entire template. SEE ALSO
debconf-getlang(1) AUTHOR
Joey Hess <joeyh@debian.org> 2012-09-10 DEBCONF-MERGETEMPLATE(1)
All times are GMT -4. The time now is 06:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy