LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
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: 7

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-
 
Old 05-01-2018, 12:20 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by chinita View Post
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.
Does it have to be a "script.sh"?
Code:
alias lsv="ls /var/"
in .bashrc
Logput and back in, open a terminal and type
Code:
lsv
Ta da. More robust solutions are around, and it is a modest requirement.

https://ryanstutorials.net/bash-scripting-tutorial/

Have Fun!

Last edited by Habitual; 05-01-2018 at 12:26 PM.
 
Old 05-01-2018, 06:16 PM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Code:
stuff="$(echo -e ls /var | wc -w)"
echo $stuff
stuff="$(echo -e ls /var/* )"
echo $stuff
stuff="$(ls /var/* )"
echo $stuff
variations.
 
Old 05-28-2020, 02:29 PM   #6
GeorgeawAke
LQ Newbie
 
Registered: May 2020
Location: Australia
Distribution: GeorgeawAkeLE
Posts: 3

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

actually grub works pretty smoothly i have found... but in my installing Slackware 9.1 I found that LILO isnt that hard to use if you just do it... I know have slackware and xp dualbooted and done it all by accident
 
Old 05-28-2020, 02:50 PM   #7
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,666

Rep: Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970Reputation: 7970
Quote:
Originally Posted by GeorgeawAke View Post
actually grub works pretty smoothly i have found... but in my installing Slackware 9.1 I found that LILO isnt that hard to use if you just do it... I know have slackware and xp dualbooted and done it all by accident
Is there a point to this post? Not related in any way to the OP's original question, and this thread had been closed for two years before this. Or is it more about your posting signature and spamming?
 
  


Reply



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 11:24 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
Open Source Consulting | Domain Registration