tag:blogger.com,1999:blog-8032022811235182759.post627393483190634482..comments2024-03-23T08:25:23.254-07:00Comments on Linux Commando: Using awk to extract lines in a text filePeter Leunghttp://www.blogger.com/profile/05589860210899238688noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-8032022811235182759.post-80823551488120302132017-03-21T05:15:04.972-07:002017-03-21T05:15:04.972-07:00file.txt
line1
line2
line3
i need to assign each...file.txt<br /><br />line1<br />line2<br />line3<br /><br />i need to assign each line to a variable like<br /><br />a=line1<br />b=line2 <br />thotahttps://www.blogger.com/profile/01851872796908030802noreply@blogger.comtag:blogger.com,1999:blog-8032022811235182759.post-30535425242323999682012-12-14T06:57:30.429-08:002012-12-14T06:57:30.429-08:00Much appreciated, especially for a Linux newbie! G...Much appreciated, especially for a Linux newbie! Glad I found this blog :-)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8032022811235182759.post-55363196313311908782012-11-07T06:58:11.419-08:002012-11-07T06:58:11.419-08:00What if you would like only the first word from a ...What if you would like only the first word from a line (or for the same matter the second word). Words are separated by single space.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8032022811235182759.post-78478446586171808942012-10-03T01:13:41.249-07:002012-10-03T01:13:41.249-07:00@marwa: no, this is a correct example:
COUNT=1;
f...@marwa: no, this is a correct example:<br />COUNT=1;<br />for i in `nvram show | grep traff- | cut -f1 -d=""`;<br />do<br />NEW=` nvram show | grep traff- | awk 'NR == a {print}' a=$COUNT`<br />echo $NEW<br />doneAlexandrescu Sergiuhttps://www.blogger.com/profile/13688152875753718887noreply@blogger.comtag:blogger.com,1999:blog-8032022811235182759.post-90285084479897405002012-01-26T09:45:06.029-08:002012-01-26T09:45:06.029-08:00is it possible to make NR equal variable I entered...is it possible to make NR equal variable I entered before ?!!<br /><br />like this example :<br />awk -F: '{if(NR==$no) {print $0}}' /etc/passwd<br /><br />it is right or not : NR==$nomarwanoreply@blogger.comtag:blogger.com,1999:blog-8032022811235182759.post-55366764746083758942011-03-27T00:15:10.542-07:002011-03-27T00:15:10.542-07:00want to pull a number of lines from a long file us...want to pull a number of lines from a long file using a specific formula<br /><br />n (number of iterations in a loop)<br />a (offset number)<br />b (stretch factor)<br /><br />example with n {1..100}<br /><br />for (( n=1; n<101; n++ )); do awk -v n=$n 'NR==a+(b*n)' a=0 b=1 inputfile >>outputfilesgruenwaldhttps://www.blogger.com/profile/11564906004927744406noreply@blogger.comtag:blogger.com,1999:blog-8032022811235182759.post-41861723275566211442008-06-17T11:01:00.000-07:002008-06-17T11:01:00.000-07:00I'm having trouble using the print every nth comma...I'm having trouble using the print every nth command inside an actual script, basically I'm using awk to split a long string of characters into having each be its own line using the split "" command, then I wanna pull out every 1001-1003 character, any suggestions?Anonymoushttps://www.blogger.com/profile/11600854028131665692noreply@blogger.com