Sponsored Content
Top Forums UNIX for Dummies Questions & Answers awk construct unfamiliar to me Post 302678597 by Scrutinizer on Saturday 28th of July 2012 05:09:22 PM
Old 07-28-2012
I would put forward though that leaving out the default action {print $0} is no more a short-cut than leaving out the default condition 1, and also print prints the default value, which is $0 (and the semicolons are unnecessary). So in full it would be..
Code:
awk '
   1 {
     for( i=2; i<=NF; i++ )
       if( $i == $1 )
         $i = RS $i
   }

   1 { 
     print $0
   }
' infile

Which can of course be combined into 1 block, since the condition is the same (like agama did in post #2)..

I sometimes have a preference for one-liners because I think they are sometimes easier to read (but only if they are short, true one-liners (fewer than 65 characters), and they are great for cutting and pasting or just composing on the command line..

Last edited by Scrutinizer; 07-28-2012 at 06:17 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with looping construct

Hi all I have tried to search for this, but keep getting a MySQL db connect error, so am posing the question here, and taking a risk of incurring the wrath of the mods with my first post... I have the following test script: #!/bin/bash HTTPD=`/bin/ps -axcu | /usr/bin/grep httpd... (6 Replies)
Discussion started by: mikie
6 Replies

2. Shell Programming and Scripting

ksh construct

Hi Guys, could someone tell me what this ksh construct does typeset -r PROG_PWD=${0%/*} does I understand the -r for readonly but I would very much appreciate a definitive account of what this will set $PROG_PWD to. If I run this at the cmd line it it gets set to /usr/bin but I would... (2 Replies)
Discussion started by: ajcannon
2 Replies

3. UNIX for Advanced & Expert Users

unfamiliar errors

I was checking my error logs today and ran into some errors I have not seen before maybe somebody has run into these before? /etc/cron.quarter-hourly/owusers.sh: Set effective gid to mail(12) failed! /usr/local/mailwatch/check_sendmail_relay.sh: line 8: thanks (1 Reply)
Discussion started by: mcraul
1 Replies

4. Shell Programming and Scripting

if-else construct not working

Hi all, Sorry to ask this easy question but I am stuck. In a scenario i am executing one shell script which contains a if - else construct : if ; then echo $line $line >> successful_build.txt else $line >> failed_services.txt fi explaination : if the... (5 Replies)
Discussion started by: bhaskar_m
5 Replies

5. Shell Programming and Scripting

syntax error in the if construct

Hi can anyone tell me why is this code giving error mode=$1 if ] || ] then echo "MODES:" exit 1 fi Thanks (5 Replies)
Discussion started by: Anteus
5 Replies

6. Shell Programming and Scripting

Unfamiliar array syntax

I recently was handed responsibility for a script which has array references that are new to me and I could use some help understanding them. Parts of the config file and script are included. This script collects backups from a jail server of the jails running on that host. Several jail... (1 Reply)
Discussion started by: thumper
1 Replies

7. Shell Programming and Scripting

Help with if-else construct

Hi all i have been trying to do a small 'question and answer' script using if-else statement and a combination of pipe. I have succeeded in allowing the user to login with user name and password stored in a sequence username/password in a file named "pass" like this: echo "please enter your... (14 Replies)
Discussion started by: arikutex
14 Replies

8. Shell Programming and Scripting

Construct path

Hi, I need to construct the below path from the two available directory path, O/P /home/data/test/run/ht/WEB/HTML /home/data/test/run/ht/WEB/JSP /home/data/test/run/ht/WEB/CSS Path:1 ------ /home/data/test/run/ Path:2 ------ /home/data/share/app/01/lang/ht/WEB/HTML... (5 Replies)
Discussion started by: vel4ever
5 Replies

9. Shell Programming and Scripting

How would I construct a (possibly simple) IF statement?

Hi all, I thought this would be simple, but I've been having a lot of trouble trying to write this IF statement, if I may ask for help pls: In BASH, how would I construct the if statement: Should ONLY be true if USEROPTscript=="yes"]] AND $mode=="INSTALL" /or/ $mode=="CHANGE" ]]... (3 Replies)
Discussion started by: jmccoughlin
3 Replies
debugfs.reiser4(8)						reiser4progs manual						debugfs.reiser4(8)

NAME
debugfs.reiser4 - the program for debugging reiser4 filesystem. SYNOPSIS
debugfs.reiser4 [ options ] FILE DESCRIPTION
debugfs.reiser4 is reiser4 filesystem debug program. You can disscover the internal reiser4 filesystem structures by using it. COMMON OPTIONS
-V, --version prints program version. -?, -h, --help prints program help. -y, --yes assumes an answer 'yes' to all questions. -f, --force forces debugfs to use whole disk, not block device or mounted partition. -c, --cache N sets tree cache node number to passed value. This affects very much behavior of libreiser4. It affects speed, tree allocation, etc. BROWSING OPTIONS
-k, --cat browses passed file like standard cat and ls programs. PRINT OPTIONS
-t, --print-tree prints the internal tree. -b, --print-block N prints the block associated with the passed block number. -n, --print-nodes FILE prints all nodes that the passed file lies in. -i, --print-file prints all items that the passed file consists of. -s, --print-super prints the both super blocks: master super block and format specific one. -j, --print-journal prints the journal with not yet commited transactions (if any). -a, --print-alloc prints the block allocator data. -d, --print-oid prints the oid allocator data. METADATA OPTIONS
-P, --pack-metadata fetches filesystem metadata and writes them to the standard output. -U, --unpack-metadata reads filesystem metadata stream from the stdandard input and constructs a new filesystem based on the metadata. debugfs.reiser4 --pack-metadata <FS1> | debugfs.reiser4 --unpack-metadata <FS2> and then debugfs.reiser4 --pack-metadata <FS2> produces a stream equivalent to the first one. PLUGIN OPTIONS
-p, --print-profile prints the plugin profile. This is the set of default plugins used for all parts of a filesystem -- format, nodes, files, directo- ries, hashes, etc. If --override is specified, then prints modified plugins. -l, --print-plugins prints all plugins libreiser4 knows about. -o, --override TYPE=PLUGIN, ... overrides the default plugin of the type "TYPE" by the plugin "PLUGIN" in the plugin profile. Examples: debugfs.reiser4 -o nodeptr=nodeptr41,hash=rupasov_hash /dev/hda2 REPORTING BUGS
Report bugs to <reiserfs-devel@vger.kernel.org> SEE ALSO
measurefs.reiser4(8), mkfs.reiser4(8), fsck.reiser4(8) AUTHOR
This manual page was written by Yury Umanets <umka@namesys.com> reiser4progs 02 Oct, 2002 debugfs.reiser4(8)
All times are GMT -4. The time now is 11:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy