Sponsored Content
Top Forums Shell Programming and Scripting Capture the last record number using "awk" NR variable Post 302991240 by jim mcnamara on Wednesday 8th of February 2017 08:15:48 AM
Old 02-08-2017
Consider
Code:
wc -l

which is meant to give number of records.

Code:
count=`wc -l < abc.txt`

awk is a great tool. However there are lots of useful unix tools, which you may want to consider
This User Gave Thanks to jim mcnamara For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to count number of occurrences of a "|" from a variable?

I have a variable, var="some1|some2|some3" I want to know how many "|" are in $var. When I say echo $var | grep -c '|' I am getting only 1 :confused: :confused: :confused: ? (4 Replies)
Discussion started by: jingi1234
4 Replies

2. Shell Programming and Scripting

How do "if [ $variable -eq "a number" ] ?

In particular I'm trying to check if a line contains an IP address and then do something with it. The file contains some lines that have no numbers, some blank lines, and some lines with only IP addresses. #!/bin/bash touch file2.txt cat file1.txt | \ while read line do if *.*.*.* ];... (4 Replies)
Discussion started by: earnstaf
4 Replies

3. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

4. Shell Programming and Scripting

Sed - How to escape variable number of "/" (slash) ?

Hi, Can you tell me how to escape a variable number of slash characters in sed "/" ? In the script the code looks like this: cat $file_to_update | sed s/^$param/$param=$tab2*\#\*/1 And the $tab2 value is a path so it will have a number of "/" charracters. # cat db.cfg | sed... (4 Replies)
Discussion started by: majormark
4 Replies

5. Shell Programming and Scripting

help for saving vertical datas to horizontal with "awk" or "cut"

hi, i have a file having datas like that ./a.txt 12344 12345 12346 12347 ..... ..... ... i want to save this datas to another file like that ./b.txt 12344 12345 12346 12347 ... ... ... i think awk can make this but how? :) waiting for ur help. (3 Replies)
Discussion started by: mercury
3 Replies

6. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

9. Shell Programming and Scripting

Variable interpolation in "print" of awk command

Hi, I have a snippet like below. Based on variable i, i wish to print 1,2,3,4,5th columns to Sample files. For each loop, one column from contetn and results will be pused to sample files. But i have a problem here i=1 while ; do `awk -F"\t" '{print $($i)}' $content > Sample_${i}_original`;... (4 Replies)
Discussion started by: forums123456
4 Replies

10. Shell Programming and Scripting

awk variable into shell command "date -d": possible...?

Hello, there! I am trying to pass an awk variable into a shell command in order to collect the result into an awk variable; in Bash it does work, as in: v='2'; date -d "now + $v weeks" But in awk it does not, as in: v="2" "date -d 'now + v weeks'" | getline newdate close ("date -d 'now... (3 Replies)
Discussion started by: fbird3
3 Replies
GPHOTO2(1)																GPHOTO2(1)

NAME
gphoto2 - command-line gphoto2 client SYNOPSIS
gphoto2 [--debug] [-q | --quiet] [-v | --verbose] [-h | --help] [--list-cameras] [--usb-usermap-script NAME] [--print-usb-usermap] [--list-ports] [--stdout] [--stdout-size] [--auto-detect] [--port PATH] [--speed SPEED] [--camera MODEL] [--filename FILENAME] [--usbid USBID] [-a | --abilities] [--folder FOLDER] [[-R | --recurse] | --norecurse] [-l | --list-folders] [-L | --list-files] [-m NAME | --mkdir NAME] [-r NAME | --rmdir NAME] [-n | --num-files] [-p RANGE | --get-file RANGE] [-P | --get-all-files] [-t RANGE | --get-thumbnail RANGE] [-T | --get-all-thumbnails] [-r RANGE | --get-raw-data RANGE] [--get-all-raw-data] [--get-audio-data RANGE] [--get-all-audio-data] [-d RANGE | --delete-file RANGE] [-D | --delete-all-files] [-u FILENAME | --upload-file FILENAME] [--capture-preview] [--capture-image] [--capture-movie] [--capture-sound] [--capture-show-info RANGE] [--summary] [--manual] [--about] [--shell] DESCRIPTION
gphoto2(3) is a cross-platform digital camera library, and gphoto2(1) is a command-line client for it. Where an option takes a range of files, thumbnails, or other data, they are numbered beginning at 1. A range is a comma-separated list of numbers or spans (``first-last''). Ranges are XOR (exclusive or), so that ``1-5,3,7'' is equivalent to ``1,2,4,5,7''. --debug Turn on debugging. -q, --quiet Quiet output (default=verbose). -v, --version Display version and exit. -h, --help Display a short usage message. --list-cameras List supported camera models. --usb-usermap-script NAME Use NAME as the hotplug usb script used in the output of --print-usb-usermap. Default is "usbcam". --print-usb-usermap For every camera supported by your version of gphoto2, print the corresponding line for inclusion into the usb.usermap hotplug con- fig file. The script name used in these lines is specified with the --usb-usermap-script option. --list-ports List supported port devices. --stdout Send file to stdout. --stdout-size Print filesize before data. --auto-detect List auto-detected cameras. --port PATH Specify port device. --speed SPEED Specify serial transfer speed. --camera MODEL Specify camera model. Most model names contain spaces: remember to enclose the name in quotes so that the shell knows it is one parameter. For example: --camera "Kodak DC240". --filename FILENAME Specify a filename. --usbid USBID (Expert only) Override USB IDs. -a, --abilities Display camera abilities. -f, --folder FOLDER Specify camera folder (default="/"). -R, --recurse Recursion (default for download). --no-recurse No recursion (default for deletion). -l, --list-folders List folders in folder. -L, --list-files List files in folder. -m, --mkdir NAME Create a directory. -r, --rmdir NAME Remove a directory. -n, --num-files Display number of files. -p, --get-file RANGE Get files given in range. -P, --get-all-files Get all files from folder. -t, --get-thumbnail RANGE Get thumbnails given in range. -T, --get-all-thumbnails Get all thumbnails from folder. -r, --get-raw-data RANGE Get raw data given in range. --get-all-raw-data Get all raw data from folder. --get-audio-data RANGE Get audio data given in range. --get-all-audio-data Get all audio data from folder. --delete-files RANGE Delete files given in range. --delete-all-files Delete all files in folder. -u, --upload-file FILENAME Upload a file to camera. --capture-preview Capture a quick preview. --capture-image Capture an image. --capture-movie Capture a movie. --capture-sound Capture an audio clip. --show-info RANGE Show info. --summary Summary of camera status. --manual Camera driver manual. --about About the camera driver. --shell Start the gphoto2 shell, an interactive environment. See SHELL MODE for a detailed description. SHELL MODE
The following commands are available: cd Change to a directory on the camera. lcd Change to a directory on the local machine. exit, quit, q Exit the gphoto2 shell. get Download the file to the current directory. get-thumbnail Download the thumbnail to the current directory. get-raw Download raw data to the current directory. show-info Show information. delete Delete a file or directory. show-exif Show EXIF information (only if compiled with EXIF support). help, ? Displays command usage. ls List the contents of the current directory on the camera. SEE ALSO
gphoto2(3), gphoto2.txt, gphoto2-cli.txt, http://www.gphoto.org/ EXAMPLES
gphoto2 --list-files List files on camera. gphoto2 --get-file 7-13 Get files number 7 through 13 from the list output by gphoto2 --list-files. gphoto2 --usb-usermap-script gphoto2cam --print-usb-usermap >> /etc/hotplug/usb.usermap Append a line to the hotplug config file /etc/hotplug/usb.usermap for every supported camera, using /etc/hotplug/usb/gphoto2cam for setting up permissions correctly. AUTHOR
The gPhoto2 Team. Man page edited by Tim Waugh <twaugh@redhat.com>. February 2002 GPHOTO2(1)
All times are GMT -4. The time now is 08:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy