Linux download csv file

Linux download csv file

linux download csv file

CSV file uses Linux/Unix style end-of-line characters (/n); All parent descriptions appear in rows above. Linux Script To Export CSV File. kenbryant. by kenbryant ∙ Apr 5th, 2019 at 7:​18am. Needs Answer General Linux. Hello All,. I have a script that I use that works. This tutorial shows you how to export data in the SQLite database to a CSV file using sqlite3 and SQLite Studio tools. linux download csv file

Linux Script To Export CSV File

Hello All,

I have a script that I use that works well.  This script ssh's to several servers and lists all the accounts on each server.   But I need more detailed information.  My current script lists the name of the server and the GECOS information in a CSV file.  What I need exported to a CSV file is the following columns and data:

ServerName OS UserID/Account Name GECOS Information Status*  LastLogon Groups

*Status is whether or not the account is enabled or disabled.

The data should look like the following example:

SERVEROSUSERIDUSER_DESCRIPTIONSTATUSLASTLOGONGROUPS
bet2dbadm01Linuxadish897/I/A468629/SCP/Smith, John/ULN SAEnabled4/5/2019admin

Here is my current script:

#!/bin/sh#Variables_list_of_servers="PorkyPig DonaldDuck Goofy"# Main Codefor _server in $_list_of_serversdossh $_server"hostname" 2>&1 if[$? -gt 0 ]thenecho"Couldn't SSH to server $_server"| mail -s "Error connecting to $_server" John.Smith@abc.com elseecho -e ssh $_server cat /etc/passwd | awk -F : '{ print $1 " " $5 }' 2>&1 fidone > All_Unix_Linux_$(date +"%m%d%Y").csv

Popular Topics in General Linux
Which of the following retains the information it's storing when the system power is turned off?
88% of IT pros got this right.

4 Replies

Loop through the /etc/passwd file, setting the first field to a variable, like  User_id.

Then in the loop, run

to see the last login of the user, and from where they logged in.

ElRoasto
This person is a verified professional.
Verify your account to enable IT peers to see that you are a professional.
Apr 8, 2019 at 21:49 UTC

Can you give me an example of how that would look?  I am a newbie when it comes to writing scripts.

Paste the following into a script file (not at the command line in a terminal session), and run it.  Read the comments (#) at the end of each line.

while read -a _line #reads line into the array variable "_line"do IFS=: #sets the internal field separator variable (IFS) to colon ":" matching the /etc/passwd file's field separatorecho${_line[0]}${_line[6]}#prints the first and seventh array elementsdone < /etc/passwd #"read" takes its input from redirected file

Or you could paste this form of the command at a shell prompt:

while read -a _line ;do IFS=:;echo${_line[0]}${_line[6]};done < /etc/passwd

The "echo" is just an illustration.  You can replace that with whatever logic you require.

This topic has been locked by an administrator and is no longer open for commenting.

To continue this discussion, please ask a new question.

Источник: [https://torrent-igruha.org/3551-portal.html]

Linux download csv file

2 thoughts to “Linux download csv file”

Leave a Reply

Your email address will not be published. Required fields are marked *