INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

what the following command is doing ?

what the following command is doing ?

(OP)
Plesae let me know what the following command is doing ..

Could not able to understand ..

print $(wc -l $InputFileSrc | awk '{ print $2 "|"$1 "|" }')$(cksum $InputFileSrc | awk '{ print $1 }') | awk -F"[ /]" '{ print $NF }'

thanks/Mike

RE: what the following command is doing ?


CODE

print $( -- Prints the following (string):
wc -l $InputFileSrc            <--count lines in $InputFileSrc file
| awk '{ print $2 "|"$1 "|" }' <--piped into awk which will concat and print $2=file name, '|', line count
) concatenated to the following string:
$(
cksum $InputFileSrc |           <-- checksum of same file piped into awk
awk '{ print $1 }') |           <-- which prints the first field, ends the string and pipes into...
awk -F"[ /]" '{ print $NF }'    <-- which sets the input field separator to space+/ and 
                                    prints the number of fields. 
3eyes

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: what the following command is doing ?


PS: This part does nothing because the resulting string has no spaces or '/'s:

CODE

.... | awk -F"[ /]" '{ print $NF }' 

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

RE: what the following command is doing ?


it just echo two $(...)

CODE

# InputFileSrc=file
# print $(wc -l $InputFileSrc | awk '{ print $2 "|"$1 "|" }')$(cksum $InputFileSrc | awk '{ print $1 }') | awk -F"[ /]" '{ print $NF }'
file|2|3115234434
# 

and step by step:

CODE

# wc -l $InputFileSrc
       2 file
# wc -l $InputFileSrc | awk '{ print $2 "|"$1 "|" }'
file|2|
# print $(wc -l $InputFileSrc | awk '{ print $2 "|"$1 "|" }')
file|2|
# cksum $InputFileSrc
3115234434 8 file
# cksum $InputFileSrc| awk '{ print $1 }'
3115234434
# print $(cksum $InputFileSrc | awk '{ print $1 }')
3115234434
# print "file|2|3115234434"
file|2|3115234434
# print "file|2|3115234434"|awk -F"[ /]" '{ print $NF }'
file|2|3115234434
# 

so the last piped awk has nothing to do in above sample, but in below input it does

CODE

# InputFileSrc=/tmp/dd/file
# print $(wc -l $InputFileSrc | awk '{ print $2 "|"$1 "|" }')$(cksum $InputFileSrc | awk '{ print $1 }')
/tmp/dd/file|2|3115234434
# printf "/tmp/dd/file|2|3115234434" | awk -F"[ /]" '{ print $NF }'
file|2|3115234434
# 


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close