LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 04-12-2018, 12:58 AM   #1
chinita
LQ Newbie
 
Registered: Mar 2018
Posts: 7

Rep: Reputation: Disabled
How to create script for ls command for var folder


Hi,

I would like to seek for your assistance on my ongoing ls bash scripting.

I need to create a script to get the content of my var folder. Please help me on this.

Here is my current script:

#!/bin/bash

ls -lar /var


Or please suggest any script that I could put on the server.. Really appreciate all your help. Thank you.

Last edited by chinita; 04-12-2018 at 01:43 AM.
 
Old 04-12-2018, 02:58 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,261

Rep: Reputation: 315Reputation: 315Reputation: 315Reputation: 315
Your current script works ok - display contents of /var. Please describe more exactly your problem.
 
Old 04-20-2018, 02:58 AM   #3
myersmk
LQ Newbie
 
Registered: Apr 2018
Location: San Diego
Distribution: Enterprise Linux (CentOS/RHEL)
Posts: 5

Rep: Reputation: Disabled
Content for?

Your script is fine if all you want to know is what's in that directory. More insight as to what you're trying to accomplish will help us to help you. For example is this to be ran as a schedule job? Are you interested in files only, or directories, or both? ls will give you the basics to gather whatever is within the /var directory but if something more robust is needed, locate and find are better alternatives....example: this is a super simple example but will retrieve the contents

find /var | cut -c2-
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create folder using script LinpusKelvin Linux - Newbie 8 06-23-2010 12:00 PM
Script query - trying to create a folder with an environment variable BHuckfield Linux - Server 10 05-21-2010 02:42 AM
Help with bash script to create directory to /home folder wegadnie Linux - General 5 10-25-2008 11:50 AM
Help create perl script for delete file/folder sportivo888 Linux - Newbie 5 12-05-2007 11:33 PM
How to create command to start a program without going to that folder? janestclaire Linux - Newbie 6 08-31-2005 07:42 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration