Sponsored Content
Top Forums Shell Programming and Scripting Building a Linux like LS for Unix Post 44339 by 435 Gavea on Thursday 4th of December 2003 01:24:19 PM
Old 12-04-2003
Building a Linux like LS for Unix

I'm trying to customize my environment at work in a Unix system.
So I'm starting with the ls command...

I'd like to make it run as the Linux ls...
Even in color, if possible...

My first problem is to make the file listing brake in columns...
In fact, the actual ls from Unix does this, but I'm trying to make my own ls command...

For now I've coded the following:
______________________________________________
#!/bin/ksh

COL_NUM=0

LINE_NUM=`ls | wc -w | tr -d" "`

ls -lF | tr -s " " | cut -d" " -f9 | sort -d |
while read -r FIELD
do
if [ `expr "$COL_NUM" % 5` - ne 0 ]; then
echo "$FIELD\t\c"
else
COL_NUM=0
echo "\n$FIELD\t\c"
fi
COL_NUM=`expr "$COL_NUM" + 1`
done

echo ""
______________________________________________

I wonder how the ls does this...

And, further, I'd like to display the files like the Linux does - each type of file has its own colour.

How do I print in colour in shell ?

Thanks in advance,
=== 435 Gavea ===
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

building and running a software in different linux kernel versions

my Querry is if i build a software on a specific linux kernel and then try to run it on another linux kernel ....what can be the possible problems or what errors can most probably appear while running the binary in an updated version of linux. (1 Reply)
Discussion started by: mobydick
1 Replies

2. UNIX for Dummies Questions & Answers

Building from scratch - UNIX

Hi! Any knows if Unix (from IBM, Sun, HP, etc) is picky on hardwares? I mean, installing Unix (not Linux) on a custom build system? Thanks. (2 Replies)
Discussion started by: genesisX
2 Replies

3. Shell Programming and Scripting

Need help in building Unix script

Hi all, We have a requirement like, There will be a file. For example the content will be as follows +=KA100012345678 0114092150R328abcdefgh D 345626 011409 1 2121212 232323 12121212 2323232323 1212121 We need to select the bold portion and change it to a... (11 Replies)
Discussion started by: susant.igate
11 Replies

4. Shell Programming and Scripting

Need help in building Unix script

Hi all, We have a requirement like we need to create a program which will change a particular string in the file. For example +=KA1238767 1121 3344645 686943 22356 01 567893 12435 12121 983627 121 1092 091217 02 may be for engine failure In the above file we need to change the bold string... (2 Replies)
Discussion started by: susant.igate
2 Replies

5. High Performance Computing

Building a Linux Virtual Server cluster

Hi Guys, I'm busy building a LVS-NAT cluster on Red-Hat server 5.1 and I need a kernel that has LVS capabilities for a red-hat server 5.1. Is the anyone who can advise me where I can get this kernel. I have already visited the following site Ultra Monkey: and this has old kernels e.g. 2.4.20... (2 Replies)
Discussion started by: Linux Duke
2 Replies

6. Shell Programming and Scripting

Building a script in Ubuntu (Linux) from existing DOS .cmd

Greetings, I would be very grateful to anyone who is willing to help and knows there scripting and how to convert a DOS CMD script. :) In this posting I am also hoping to pass on information to anyone wanting to see a bit of VMware command line stuff. I have made a script (batch file) that runs... (11 Replies)
Discussion started by: dp123
11 Replies

7. UNIX for Advanced & Expert Users

Building a Unix Server from Scratch?

Hello Everyone, This post is a result of my search and quest to build a Unix Server at Home. I am familiar with the most of the systems such as, Solaris 10, HP-UX & Linux. Can somebody help me with more information about How to Build a Unix Server right from Fundamentals.... ? I have... (5 Replies)
Discussion started by: Vabiosis
5 Replies

8. Shell Programming and Scripting

extension building make GNU Linux

Hi, I do "touch poub.mlc" Download my Makefile, But when I try : make -f Makefile.txt(.txt in order my file to be accepted for upload), it says:"no rule for poub.mlo target" What is wrong in my Makefile(test yourself please before posting)? (1 Reply)
Discussion started by: synhedionn
1 Replies

9. High Performance Computing

Building Linux cluster for mechanical engineering software

Hello everybody, I'm new here in the forum and first i will greet everybody. Also I'm new with the issue of HPC, but I have to inform my urgently. My issue: I'm a mechanical engineer, specialised on simulation like fluid dynamics (CFD) and FEM. Especially I'm programming software for... (6 Replies)
Discussion started by: biro
6 Replies

10. UNIX for Dummies Questions & Answers

Error building program in UNIX

I'm trying to build a program and I'm getting a series of messages that I don't understand (new to UNIX): make: Entering directory `/disk/cg6/ccoda/code/proj/abrupt/exp/cam1/models/atm/cam/tools/scam/ui' g++ -c -Wall -g -DLINUX -DREAL_TYPE=double -DNeedFuncProto ... (7 Replies)
Discussion started by: bstephens
7 Replies
NSAPI_VIRTUAL(3)							 1							  NSAPI_VIRTUAL(3)

nsapi_virtual - Perform an NSAPI sub-request

SYNOPSIS
bool nsapi_virtual (string $uri) DESCRIPTION
nsapi_virtual(3) is an NSAPI-specific function which is equivalent to <!--#include virtual...--> in SSI ( .shtml files). It does an NSAPI sub-request. It is useful for including CGI scripts or .shtml files, or anything else that you'd parse through webserver. To run the sub-request, all buffers are terminated and flushed to the browser, pending headers are sent too. You cannot make recursive requests with this function to other PHP scripts. If you want to include PHP scripts, use include(3) or require(3). Note This function depends on a undocumented feature of the Netscape/iPlanet/Sun webservers. Use phpinfo(3) to determine if it is avail- able. In the Unix environment it should always work, in Windows it depends on the name of a ns-httpdXX.dll file. Read the note about subrequests in the NSAPI section (UNIX, Windows) if you experience this problem. PARAMETERS
o $uri - The URI of the script. RETURN VALUES
Returns TRUE on success or FALSE on failure. PHP Documentation Group NSAPI_VIRTUAL(3)
All times are GMT -4. The time now is 08:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy