Skip to content

Instantly share code, notes, and snippets.

@ashleymavericks
Last active January 31, 2023 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashleymavericks/26c4ae0dbc2f24dfcc05a7ca7b5c7f7f to your computer and use it in GitHub Desktop.
Save ashleymavericks/26c4ae0dbc2f24dfcc05a7ca7b5c7f7f to your computer and use it in GitHub Desktop.
Broad Market NSE indices
#!/bin/bash
# fetch csv using wget and write to stdout -> remove header row from the csv -> replace &/- with _ -> select only stock_symbol column -> finally redirect output to a text file
# using cut
wget -O - https://www1.nseindia.com/content/indices/ind_nifty50list.csv | sed 1d | sed 's/[&-]/_/g' | cut -d ',' -f 3 > "Broad 5 - Microcap 250".txt
# using awk
wget -O - https://www1.nseindia.com/content/indices/ind_niftymicrocap250_list.csv | sed 1d | sed 's/[&-]/_/g' | awk -F ',' '{print $3}' > "Broad 5 - Microcap 250".txt
wget -O - https://www1.nseindia.com/content/indices/ind_niftysmallcap250list.csv | sed 1d | sed 's/[&-]/_/g' | awk -F ',' '{print $3}' > "Broad 4 - Smallcap 250".txt
wget -O - https://www1.nseindia.com/content/indices/ind_niftymidcap150list.csv | sed 1d | sed 's/[&-]/_/g' | awk -F ',' '{print $3}' > "Broad 3 - Midcap 150".txt
wget -O - https://www1.nseindia.com/content/indices/ind_niftynext50list.csv | sed 1d | sed 's/[&-]/_/g' | awk -F ',' '{print $3}' > "Broad 2 - Nifty Next 50".txt
wget -O - https://www1.nseindia.com/content/indices/ind_nifty50list.csv | sed 1d | sed 's/[&-]/_/g' | awk -F ',' '{print $3}' > "Broad 1 - Nifty 50".txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment