Sponsored Content
Top Forums Shell Programming and Scripting Script solution as singleline ? Post 302971540 by msuluhan on Thursday 21st of April 2016 12:59:41 PM
Old 04-21-2016
Quote:
Originally Posted by RavinderSingh13
Hello msuluhan,

Could you please try following and let me know if this helps you, as I don't have your find command's output so I couldn't test it.
Code:
find path -type d | awk -vs1="\"" -F "/" 'NF == 4{gsub(/custype=/,"custype=" s1,$0);gsub("/logdate",s1"/logdate",$0);print $3}'

Thanks,
R. Singh
Hello

Thanks for your reply, here is the output

Code:
$find 20160415/custstat -type d | awk -vs1="\"" -F "/" 'NF == 4{gsub(/custype=/,"custype=" s1,$0);gsub("/logdate",s1"/logdate",$0);print $3}'
custtype=1234567"
custtype=Type111112"


------------------------------------------------------------------------

Hello Scrutinizer

I tried your advice like following line if I understand correctly

Code:
find 20160415/custstat -type d | sed 's|custype=\([^/]*\)/|custype="\1"=|'

sed does not change any output, output like

Code:
20160415/custstat
20160415/custstat/custtype=1234567
20160415/custstat/custtype=1234567/logdate=20160415
20160415/custstat/custtype=Type111112
20160415/custstat/custtype=Type111112/logdate=20160415

Thanks
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please suggest a script or solution?

I have to solve a programming problem for my wife who is engaged in Research in Breast Cancer. 1. She has frequently to search a long single line of alphabetic characters (lower case) for an exact match of a string. e.g.... (4 Replies)
Discussion started by: nmsinghe
4 Replies

2. UNIX for Dummies Questions & Answers

How to get the script corrected to get the solution

Can anyone help it out, My Requirement: Actually i grep for the items in the atrblist (Result of it will provide the line where the item present and also the next line of where it presents)then it will be stored in $i.txt From tat result i wil grep 2nd word after getdate() word and store... (2 Replies)
Discussion started by: prsam
2 Replies

3. Shell Programming and Scripting

Merge multiline into Singleline

Hi, I'm newbie in this forum and I already searched regarding Merge multiline into singleline but I always found different result which is I don't want it like i want. Here is the data that i have it: *** ALARM 711 A1/BTS "MAD08B1 08ACPA0"U 090604 1040 RADIO X-CEIVER ADMINISTRATION BTS... (5 Replies)
Discussion started by: inteliduy
5 Replies

4. Shell Programming and Scripting

Perl script solution

Hi I need to do this thing in awk (or perl?). I try to find out how can I identify 1st and 2nd result from the OR expression in gensub: block='title Sata Mandriva kernel /boot/vmlinuz initrd /boot/initrd.img' echo "$block" | awk '{ x=gensub(/(kernel|initrd) /,"\\1XXX","g"); print x }' ... (12 Replies)
Discussion started by: webhope
12 Replies

5. Shell Programming and Scripting

Convert Singleline to Multilines

Hi All, Could you please help to get the below output: Input: J1,ELLA_1,ISDR,JJK,TRS J2,ROSTER,JACK J3,HUP ... ... ... Output: J1,ELLA_1 J1,ISDR J1,JJK J1,TRS (3 Replies)
Discussion started by: unme
3 Replies
SHTOOL-PATH.TMP(1)					      GNU Portable Shell Tool						SHTOOL-PATH.TMP(1)

NAME
shtool-path - GNU shtool command dealing with shell path variables SYNOPSIS
shtool path [-s|--suppress] [-r|--reverse] [-d|--dirname] [-b|--basename] [-m|--magic] [-p|--path path] str [str ...] DESCRIPTION
This command deals with shell $PATH variables. It can find a program through one or more filenames given by one or more str arguments. It prints the absolute filesystem path to the program displayed on "stdout" plus an exit code of 0 if it was really found. OPTIONS
The following command line options are available. -s, --suppress Supress output. Useful to only test whether a program exists with the help of the return code. -r, --reverse Transform a forward path to a subdirectory into a reverse path. -d, --dirname Output the directory name of str. -b, --basename Output the base name of str. -m, --magic Enable advanced magic search for ""perl"" and ""cpp"". -p, --path path Search in path. Default is to search in $PATH. EXAMPLE
# shell script awk=`shtool path -p "${PATH}:." gawk nawk awk` perl=`shtool path -m perl` cpp=`shtool path -m cpp` revpath=`shtool path -r path/to/subdir` HISTORY
The GNU shtool path command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Apache. It was later taken over into GNU shtool. SEE ALSO
shtool(1), which(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-PATH.TMP(1)
All times are GMT -4. The time now is 01:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy