Search Results

Search: Posts Made By: refrain
1,885
Posted By garydeena
Unless you don't have gawk read file ; drop...
Unless you don't have gawk
read file ; drop first line ; print everything before first , ; print last field after /

cat inputfile | tail +2 | awk -F, '{ print $1}' | awk -F/ '{ print $NF}'
1,885
Posted By Scrutinizer
It means replace the longest string of characters...
It means replace the longest string of characters (.*) that ends with a / (\/) and replace it with nothing (""), i.e. delete it...

The other two slashes are used to demarcate the extended regular...
1,885
Posted By RudiC
Try awk -F, 'NR>1 {sub(/.*\//,"", $1); print $1}'...
Try awk -F, 'NR>1 {sub(/.*\//,"", $1); print $1}' file2
2015_0313_090651_219.JPG
IMAG0399.JPG
DSC122.jpg
3,698
Posted By RudiC
That's because characters sort below digits. And...
That's because characters sort below digits. And it would surprise me if the outputs of the two commands were different.
To obtain the desired result with the header on top of the data, tryhead -1...
3,279
Posted By protocomm
first...
first field/secondhome/thirthintannf/fourthfoto3/and fifth2015_0313_090651_219.JPG,

-F"[/,]" has 2 field separator

If i have the field separator / the fifth print 2015_0313_090651_219.JPG,and...
3,698
Posted By Don Cragun
Sorry, I didn't notice the heading line before. ...
Sorry, I didn't notice the heading line before. Doing a numeric sort, the string DateTimeOriginal evaluates to 0 and sorts before 2015; while doing an alphanumeric sort, numbers sort before letters....
3,279
Posted By protocomm
awk -F "[/,]" 'NR>1 {print $5}' file -F...
awk -F "[/,]" 'NR>1 {print $5}' file

-F "[/,]"
Set Field Input Separator to /,

NR>1 skip the first line

{print $5} print the fifth field
3,279
Posted By Akshay Hegde
awk -F, 'FNR>1{n=split($1,A,/\//); print A[n]}'...
awk -F, 'FNR>1{n=split($1,A,/\//); print A[n]}' infile

-F,
Set input field separator comma

FNR>1
FNR is number of records relative to the current input file, since we are interested to skip...
3,279
Posted By Akshay Hegde
Other way $ awk -F,...
Other way

$ awk -F, 'FNR>1{n=split($1,A,/\//); print A[n]}' infile
2015_0313_090651_219.JPG
2015_0313_090323_155.JPG
2015_0313_090142_124.JPG
2015_0313_085929_083.JPG
2015_0313_090710_225.JPG...
3,279
Posted By protocomm
awk -F "[/,]" 'NR>1 {print $5}' file
awk -F "[/,]" 'NR>1 {print $5}' file
3,698
Posted By balajesuri
If you read from a file and write to the same...
If you read from a file and write to the same file in one operation, you'll end up corrupting the file. Work-around is to write to a temp file and then rename the temp file.
sort .... test.csv >...
3,698
Posted By Don Cragun
The sort utility actually has an option to let...
The sort utility actually has an option to let you put the output in one of the input files... Try:
sort --field-separator=',' --key=2 -n -o test.csv test.csv
Note that since : is not a numeric...
3,698
Posted By vgersh99
or: awk -F, '{t=$2;gsub("[^0-9]","",t);print...
or:

awk -F, '{t=$2;gsub("[^0-9]","",t);print t, $0}' OFS=, test.csv | sort -n -k1,1 | cut -d, -f2-
12,811
Posted By Don Cragun
It looks like vgersh99 had a simple off by one...
It looks like vgersh99 had a simple off by one error in the awk print statement's arguments that you have copied into your current script. Try the following instead:
#!/bin/bash
awk '
BEGIN { FS...
12,811
Posted By vgersh99
something to start with. awk -F',' -f...
something to start with.
awk -F',' -f refrain.awk file1 file2 where refrain.awk is:

BEGIN {
OFS=","
}
FNR==NR && FNR>1 {f1[$NF]=$1; next}

{
idx=($1 " " $2)
gsub("/", ":",idx)
...
Showing results 1 to 15 of 15

 
All times are GMT -4. The time now is 09:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy