LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   How to create script for ls command for var folder (https://www.linuxquestions.org/questions/linux-enterprise-47/how-to-create-script-for-ls-command-for-var-folder-4175627491/)

chinita 04-12-2018 12:58 AM

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.

eSelix 04-12-2018 02:58 AM

Your current script works ok - display contents of /var. Please describe more exactly your problem.

myersmk 04-20-2018 02:58 AM

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-

Habitual 05-01-2018 12:20 PM

Quote:

Originally Posted by chinita (Post 5842204)
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!

BW-userx 05-01-2018 06:16 PM

Code:

stuff="$(echo -e ls /var | wc -w)"
echo $stuff
stuff="$(echo -e ls /var/* )"
echo $stuff
stuff="$(ls /var/* )"
echo $stuff

variations.

GeorgeawAke 05-28-2020 02:29 PM

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

TB0ne 05-28-2020 02:50 PM

Quote:

Originally Posted by GeorgeawAke (Post 6128422)
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?


All times are GMT -5. The time now is 05:25 AM.