get specific information from text file or command output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get specific information from text file or command output
# 1  
Old 09-03-2012
[Solved] get specific information from text file or command output

Hello,

I would need some help, Smilie on a linux script,

I am not sure how can I separate some text file,

Text file contains something similar to this:
share "userhome_e" "/fs1_100g/FILE58/userhome" umask=022 maxusr=4294967295 netbios=FILE58
share "bu share" "/fs3_100g/FILE36/userhome" umask=022 maxusr=4294967295 netbios=FILE36

I would need to grab the sharename which is "userhome_e" and the server which is FILE58,
And make it appear as \\FILE58\userhome_e,/fs1_100g/FILE58/userhome
and \\file36\bu share,/fs3_100g/FILE36/userhome

I will appareciate any help,
# 2  
Old 09-03-2012
This makes some assumptions about the input (like netbios= always being the last on the line), but might work:

Code:
awk -F '"' '
    /share/ {
        n = split( $0, a, "=" );
        printf( "\\\\%s\\\\%s,%s\n", a[n], $2, $4 );

    }
' input-file >output-file

This User Gave Thanks to agama For This Post:
# 3  
Old 09-04-2012
Code:
awk -F"\"" '/^share/{n=split($NF,a,"=");print "\\"a[n]"\\"$2","$4}' filename

This User Gave Thanks to raj_saini20 For This Post:
# 4  
Old 09-04-2012
Thank you both guys, you resolved my issue.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get specific information from output

Hello community, I'm going crazy to analize an output via shell script and then get some information from it, here is the output: Slot 2 - MMU2 H, RAU2 X 15/A01 XPIC Enabled Autorestore Unknown Slot 3 - MMU2 H, RAU2 X 15/A01 XPIC ... (7 Replies)
Discussion started by: Lord Spectre
7 Replies

2. Shell Programming and Scripting

Missing information in output file

Gents, Using the following code i am able to output the information i need, but some of the strings are not complete due to the separator : used.. Kindly can u help me to get all string after the first : Example in the output file column 16 i should get 17/11/25 03:43:51:732000 but i... (8 Replies)
Discussion started by: jiam912
8 Replies

3. Shell Programming and Scripting

Compare output of UNIX command and match data to text file

I am working on an outage script and I run a command from the command line which tells me the amount of generator failures in my market. The output of this command only gives me three digits to identify the site by. I have a master list of all sites in a separate file, call it list.txt. If my... (7 Replies)
Discussion started by: jbrass
7 Replies

4. UNIX for Dummies Questions & Answers

Inserting information from old text file into a new text file

Hello, I'm trying to take information from a list of hundreds of subject ids (where each line is a new subject id), and insert each line into a new text file that contains the pathnames for each subject. To clarify, all subject have a similiar path name (e.g., C:\data\SUBJECT_ID\) that contains... (4 Replies)
Discussion started by: invisibledwarf
4 Replies

5. Shell Programming and Scripting

Extract specific line in an html file starting and ending with specific pattern to a text file

Hi This is my first post and I'm just a beginner. So please be nice to me. I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file? I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies

6. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

7. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

8. UNIX for Dummies Questions & Answers

Output text from 1st paragraph in file w/ a specific string through last paragraph of file w/ string

Hi, I'm trying to output all text from the first paragraph in a file that contains a specific string through the last paragraph in that file that contains that string. Previously, I was outputting just each paragraph with that search string with: cat in_file | nawk '{RS=""; FS="\n";... (2 Replies)
Discussion started by: carpenn
2 Replies

9. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies
Login or Register to Ask a Question